Open
Description
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();
Metadata
Assignees
Labels
No labels