Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno-lint no-fallthrough ignores function with never return type and Deno.exit #27966

Open
BuyMyBeard opened this issue Feb 5, 2025 · 0 comments

Comments

@BuyMyBeard
Copy link

Version: Deno 2.1.9

The Deno lint no-fallthrough is meant to prevent cases in a switch statement where code falls through to the next case because of a missing break statement. It detects if the scope is exited prematurely with a throw or a return statement, but won't handle Deno.exit and never function return type correctly:

function neverReturn() : never {
  Deno.exit(0);
}

function test() {
  const s : "a" | "b" | "c" | "d" | "e" = "a" as any;
  
  switch(s) {
    case "a":
      throw new Error();
  
    case "b":
      return;

    // Fallthrough not allowed lint warning
    case "c": 
      Deno.exit(0);

    // Fallthrough not allowed lint warning
    case "d":
      neverReturn();

    case "e":
      console.log('Got here');
      break;
  }
}

test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant