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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃拝 lint/suspicious/noFallthroughSwitchClause warns about a missing break even if TypeScript considers it unreachable due never. #3235

Closed
1 task done
lgarron opened this issue Jun 19, 2024 · 1 comment

Comments

@lgarron
Copy link

lgarron commented Jun 19, 2024

Environment information

Biome 1.5.2. This reproduces in the playground, so I think the rest of the output doesn't narrow anything down.

Rule name

lint/suspicious/noFallthroughSwitchClause

Playground link

https://biomejs.dev/playground/?code=LwAvACAAVABoAGUAcwBlACAAdAB5AHAAZQBzACAAZQBtAHUAbABhAHQAZQA6ACAAYABpAG0AcABvAHIAdAAgAHsAIABhAHIAZwB2ACwAIABlAHgAaQB0ACAAfQAgAGYAcgBvAG0AIAAiAG4AbwBkAGUAOgBwAHIAbwBjAGUAcwBzACIAOwBgAAoAZABlAGMAbABhAHIAZQAgAGcAbABvAGIAYQBsACAAewAKACAAIABjAG8AbgBzAHQAIABhAHIAZwB2ADoAIABzAHQAcgBpAG4AZwBbAF0AOwAKACAAIABjAG8AbgBzAHQAIABlAHgAaQB0ADoAIAAoAGMAbwBkAGUAPwA6ACAAbgB1AG0AYgBlAHIAKQAgAD0APgAgAG4AZQB2AGUAcgA7AAoAfQAKAAoAYwBvAG4AcwB0ACAAZwByAGUAZQB0AGkAbgBnAEMAbwBkAGUAIAA9ACAAYQByAGcAdgBbADAAXQA7AAoAcwB3AGkAdABjAGgAIAAoAGcAcgBlAGUAdABpAG4AZwBDAG8AZABlACkAIAB7AAoAIAAgAGMAYQBzAGUAIAAiAGEAIgA6ACAAewAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgAIgBoAGkAIgApADsACgAgACAAIAAgAGUAeABpAHQAKAAwACkAOwAKACAAIAB9AAoAIAAgAGMAYQBzAGUAIAAiAGIAIgA6ACAAewAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgAIgBoAG8AdwBkAHkAIgApADsACgAgACAAIAAgAGUAeABpAHQAKAAxACkAOwAKACAAIAB9AAoAIAAgAGQAZQBmAGEAdQBsAHQAOgAgAHsACgAgACAAIAAgAHQAaAByAG8AdwAgAG4AZQB3ACAARQByAHIAbwByACgAIgBJAG4AdgBhAGwAaQBkACAAZwByAGUAZQB0AGkAbgBnACAAYwBvAGQAZQAuACIAKQA7AAoAIAAgAH0ACgB9AAoA

Code from the playground link:

// These types emulate: `import { argv, exit } from "node:process";`
declare global {
  const argv: string[];
  const exit: (code?: number) => never;
}

const greetingCode = argv[0];
switch (greetingCode) {
  case "a": {
    console.log("hi");
    exit(0);
  }
  case "b": {
    console.log("howdy");
    exit(1);
    break;
  }
  default: {
    throw new Error("Invalid greeting code.");
  }
}

Expected result

Since the type of exit from node:process is (code?: number) => never, TypeScript considers any code that follows it to be unreachable.

clipboard

However, Biome shows an error in case clauses if I remove an unreachable break statement:

clipboard

I'd love it if Biome could match TypeScript's assessment in this case.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Sec-ant
Copy link
Member

Sec-ant commented Jun 19, 2024

This is a duplicate of biomejs/website#49

@Sec-ant Sec-ant closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2024
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

2 participants