
Expected behavior:
The function isNaN(param) (short-term for _Not a Number_) returns a boolean which indicates if the said param literal type is a number (return false) or not (return true). Hence, the function should accept a param with any types whatsoever, and it should be isNaN(param: any): boolean.
Actual behavior:
The function is static-typed to isNaN(number: **number**): boolean, which prevents parameter other than with a number type (and defeats the purpose of the function), leaving the only option to add //@ts-ignore to the line before it and which in turns, disables typescript on that line.
Tested on 3.6.3 and 3.7.0-dev.20191018
Playground Link:
http://www.typescriptlang.org/play/?ts=3.7-Beta#code/MYewdgzgLgBGCuBbARgUwE4wLwwIwCYBmAKFEljBCgEEA5JNTHAcgGFqAlZ44gSwloBDWgAoEKDAEoYAehkxgAC1TAA1hBgh4UADQx0qKPHRgYAM0EAbCKgB0PfkNGUa9CemlyYl3mCi+AcxgMdBB0PQB3RV4lGH4YCNRedAATBXAIXhSMQJgoaI143igNAAdjUpAbWyA
Related Issues:
None that I found so far
Related Issues: None that I found so far
Just use the term isNaN for a search to find plenty of duplicates.
The intended purpose of that function is to tell you if the value is specifically the reserved value NaN; non-number arguments are first coerced to number which is generally not what people expect. For example isNaN("8foo") is false but isNaN("foo8") is true because number coercion turns the latter into NaN.
Related Issues: None that I found so far
Just use the term
isNaNfor a search to find plenty of duplicates.
- #3947
- #4002
- #11414
- #12302
- #13227
- #15173
- #16427
- #19153
- #21065
- #23464
- #29607
- #34609
Hmm, I did do a search with 'isNaN' and 'NaN' myself, apparently there's a problem with my browser since it didn't show it. Thanks to pointing it out!
The intended purpose of that function is to tell you if the value is _specifically the reserved value
NaN_; non-number arguments are first coerced to number which is generally not what people expect. For exampleisNaN("8foo")isfalsebutisNaN("foo8")istruebecause number coercion turns the latter intoNaN.
Ah, I see, this does makes much sense then and I didn't really comprehend it before (even though I do know JS will try its 'best' to coerce when dealing with 'truthy' and 'falsy' values).
I'm gonna close this issue then. Thank you so much for all of your help!
I did do a search with 'isNaN' and 'NaN' myself
Make sure to remove the is:open filter when searching. Often related issues are closed already.