Skip to content

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

Open
@BuyMyBeard

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions