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

no-unreachable-code: handle exhaustive switch statements #652

Open
ajafff opened this issue Sep 25, 2019 · 0 comments · May be fixed by #740
Open

no-unreachable-code: handle exhaustive switch statements #652

ajafff opened this issue Sep 25, 2019 · 0 comments · May be fixed by #740
Assignees

Comments

@ajafff
Copy link
Member

ajafff commented Sep 25, 2019

function testSwitch(v: 1 | 2): number {
  switch (v) {
    case 1:
    case 2:
      return 1;
    default:
      console.log('default'); // unreachable
  }
  console.log('after'); // unreachable
}

The behavior for default should be configurable to allow for assertNever(v) calls.
Maybe we can even generalize it to allow never returning functions and throw statements.

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

Successfully merging a pull request may close this issue.

1 participant