π `lint/suspicious/noFallthroughSwitchClause` warns about a missing `break` even if TypeScript considers it unreachable due `never`.
lgarron opened this issue Β· comments
Lucas Garron commented
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
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.
However, Biome shows an error in case
clauses if I remove an unreachable break
statement:
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
Ze-Zheng Wu commented
This is a duplicate of biomejs/website#49