-
Notifications
You must be signed in to change notification settings - Fork 12.8k
NaN incorrectly narrows to 0 #36964
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
Comments
See also #32277 - would need a |
Looks like people might be slightly talking past each other here. Soundness would require that a So either:
|
Exactly this. If we can't have NaN as a type, then it shouldn't narrow for I'd also say this isn't a "suggestion", but a soundness/type safety bug! |
May I politely suggest changing the title to "NaN incorrectly narrows to 0" or something similar? I |
TypeScript Version: 3.9.0-dev.20200222
Search Terms: NaN Truthiness Falsy
Code
Expected behavior:
Type of
x
should benumber | boolean
.Since
NaN
isn't a "unit type" like0
, we can't expressNaN
without usingnumber
.Actual behavior:
Type of
x
is0 | boolean
.Playground Link: playground link
Related Issues:
#32778 (Incorrectly marked as duplicate?)
The text was updated successfully, but these errors were encountered: