-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Strange boolean-discriminant narrowing with strictNullChecks off #10564
Comments
This is correct. We don't know that |
@RyanCavanaugh While you are technically right (and I was thinking the same), when |
what is the expected behavior? |
@DanielRosenwasser I have the same question |
I'm wondering why the |
Hey, I just wanted to point out that this issue now has additional relevance in TypeScript 3.6 due to the addition of the |
I have experienced similar behaviour, and the following code helped me to work around this limitation: (Assuming we have switch (foo.discBool) {
case false:
doSomething(foo.optionalProperty);
} while this code didn't work: if (!foo.discBool) {
doSomething(foo.optionalProperty); // Error here
} |
TypeScript Version: nightly (2.1.0-dev.20160826)
Code
Expected behavior:
All three cases should behave the same.
The text was updated successfully, but these errors were encountered: