We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
TypeScript Version: [email protected]
Search Terms: switch
Code
const assertUnreachable = (x: never): void => {} const f = (x: 'a' | 'b') => { switch (x) { case 'a': { } break; case 'a': { } break; } }; const g = (x: { t1: 'a'; t2: 'a1' | 'a2' } | { t1: 'b'; t2: 'b1' | 'b2' }) => { switch (x.t1) { case 'a': { switch (x.t2) { case 'a1': { } break; case 'a2': { } break; default: { assertUnreachable(x.t2); } } } break; } };
Expected behavior:
Function f should not pass the typecheck at the second case block. Function g should pass the typecheck at assertUnreachable.
f
case
g
assertUnreachable
Actual behavior:
Function f passes the typecheck at the second case block. Function g doesn't pass the typecheck at assertUnreachable.
Note that if we put assertUnreachable in function f, it will work. So this seems to be only happening for the nested switch.
The text was updated successfully, but these errors were encountered:
This has been fixed by #29563.
Sorry, something went wrong.
ahejlsberg
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: [email protected]
Search Terms: switch
Code
Expected behavior:
Function
f
should not pass the typecheck at the secondcase
block.Function
g
should pass the typecheck atassertUnreachable
.Actual behavior:
Function
f
passes the typecheck at the secondcase
block.Function
g
doesn't pass the typecheck atassertUnreachable
.Note that if we put
assertUnreachable
in functionf
, it will work. So this seems to be only happening for the nested switch.The text was updated successfully, but these errors were encountered: