Suggestion
๐ Search Terms
x === Number.NaN
disallow comparing with Number.NaN
โ
Viability Checklist
My suggestion meets these guidelines:
- [?] This wouldn't be a breaking change in existing TypeScript/JavaScript code - this would break code containing the error
- โ
This wouldn't change the runtime behavior of existing JavaScript code
- โ
This could be implemented without emitting different JS based on the types of the expressions
- โ
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- โ
This feature would agree with the rest of TypeScript's Design Goals.
โญ Suggestion
Extend check added for #49962 to include Number.NaN in addition to global NaN.
๐ Motivating Example
function useVersionNumber(value: string) {
let versionNumber = Number(value);
if (versionNumber === Number.NaN) {
return;
}
console.log(versionNumber + 1);
}
๐ป Use Cases
Catching a developer error (incorrect NaN handling).
Suggestion
๐ Search Terms
x === Number.NaN
disallow comparing with Number.NaN
โ Viability Checklist
My suggestion meets these guidelines:
โญ Suggestion
Extend check added for #49962 to include
Number.NaNin addition to globalNaN.๐ Motivating Example
๐ป Use Cases
Catching a developer error (incorrect NaN handling).