You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: NaN truthiness falsy 0 is not the only falsy number
Code
functionf(a: number,b: string){returna&&b;}constx: string|0=f(0/0,"Hello");// should error but doesn't
Expected behavior: function f should return a string or number, since there currently is no NaN type in TS. If there was, it would return 0 | NaN | string
Actual behavior: function f returns string | 0
The text was updated successfully, but these errors were encountered:
@RyanCavanaugh I don't think this is actually a duplicate of that issue. The issue you linked is more along the lines of "these are terms in JavaScript and should exist in TypeScript".
functionbool(): boolean{returnfalse;}functionnumber(): number{returnNaN;}leta=number();letb=bool();constx=a&&b;// type = boolean | 0console.log(x);// prints NaN
I would expect the type of x here to be boolean | number
TypeScript Version: latest beta
Search Terms: NaN truthiness falsy 0 is not the only falsy number
Code
Expected behavior: function
f
should return astring
ornumber
, since there currently is no NaN type in TS. If there was, it would return0 | NaN | string
Actual behavior: function
f
returnsstring | 0
The text was updated successfully, but these errors were encountered: