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
isNaN coerces to a number with valueOf before checking (isNaN({}) === true), so it's conceivable that it should just have a wider argument type, rather than strictly number.
Since number is a subtype of Number, there's really no difference between number | Number and Number. In control flow analysis we perform subtype reduction at junction points only when the control flow type includes "foreign" types, i.e. types that don't occur in the declared type. The type guards in the if statement in combination produce the type number | Number, which then gets subtype reduced to Number if the body of the if statement. But this subtype reduction doesn't happen when the declared type itself is number | Number because the types aren't considered foreign.
TypeScript Version: build from master 8/17
Note: this doesn't happen if parameter
x
has typenumber | Number
The text was updated successfully, but these errors were encountered: