We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I tried to use switch(true) pattern in my code and found a bug. There is a similar piece of code that shows the same bug. Try it on the playground.
Playground Link: TS Playground
Code
const switchTruePattern = (value1: number | null, value2: number | null) => { switch (true) { case value1 !== null && value2 !== null: return value1 + value2; case value1 !== null: return value1; default: return value2; } };
TypeScript Version: 4.0.2
Expected behavior: TS should correctly assume that next cannot be null after the conditional statement.
Actual behavior: It throws TS2531: Object is possibly 'null'.
Related Issues: #35964
The text was updated successfully, but these errors were encountered:
Essentially a duplicate of #37178. Just the details vary slightly.
Sorry, something went wrong.
Please search a bit more diligently before logging new issues. Thanks!
No branches or pull requests
I tried to use switch(true) pattern in my code and found a bug.
There is a similar piece of code that shows the same bug.
Try it on the playground.
Playground Link:
TS Playground
Code
TypeScript Version: 4.0.2
Expected behavior:
TS should correctly assume that next cannot be null after the conditional statement.
Actual behavior:
It throws TS2531: Object is possibly 'null'.
Related Issues:
#35964
The text was updated successfully, but these errors were encountered: