IssueRaiser

Add a --strictNaNChecks option, and a NaN / integer / float type to avoid runtime NaN errors

*I have read the FAQ and looked for duplicate issues.* ## Search Terms * NaN * NaN type * Integer type ## Related Issues * [#21279: strictNullChecks safeguards against null and undefined, but not NaN ](https://github.com/Microsoft/TypeScript/issues/21279) * [#15135: NaN, Infinity and -Infinity not accepted in number literal types](https://github.com/Microsoft/TypeScript/issues/15135) * [#15351: Infinity/NaN literal type (dup)](https://github.com/Microsoft/TypeScript/issues/15351) * [#195: Suggestion: int type](https://github.com/Microsoft/TypeScript/issues/195) * [#4639: Proposal: int types](https://github.com/Microsoft/TypeScript/issues/4639) * BigInt is scheduled for TS 3.0 - [#15096 - Support for TC39 "BigInt: Arbitrary precision integers in JavaScript" proposal](https://github.com/Microsoft/TypeScript/issues/15096) ## Suggestion `NaN` has been a big source of errors in my code. I was under the impression that TypeScript (and Flow) could help to prevent these errors, but this is not really true. TypeScript can prevent *some* `NaN` errors, because you cannot add a number to an object, for example. But there are many math operations that can return `NaN`. These `NaN` values often propagate through the code silently and crash in some random place that was expecting an integer or a float. It can be extremely difficult to backtrack through the code and try to figure out where the `NaN` came from. I would like TypeScript to provide a better way of preventing runtime

Posted by ndbroadbent on Nov 27, 2018, 11:13 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

reliability (Software)

Add a --strictNaNChecks option, and a NaN / integer / float type to avoid runtime NaN errors

ndbroadbentNov 27, 2018, 11:13 AM

*I have read the FAQ and looked for duplicate issues.* ## Search Terms * NaN * NaN type * Integer type ## Related Issues * [#21279: strictNullChecks safeguards against null and undefined, but not NaN ](https://github.com/Microsoft/TypeScript/issues/21279) * [#15135: NaN, Infinity and -Infinity not accepted in number literal types](https://github.com/Microsoft/TypeScript/issues/15135) * [#15351: Infinity/NaN literal type (dup)](https://github.com/Microsoft/TypeScript/issues/15351) * [#195: Suggestion: int type](https://github.com/Microsoft/TypeScript/issues/195) * [#4639: Proposal: int types](https://github.com/Microsoft/TypeScript/issues/4639) * BigInt is scheduled for TS 3.0 - [#15096 - Support for TC39 "BigInt: Arbitrary precision integers in JavaScript" proposal](https://github.com/Microsoft/TypeScript/issues/15096) ## Suggestion `NaN` has been a big source of errors in my code. I was under the impression that TypeScript (and Flow) could help to prevent these errors, but this is not really true. TypeScript can prevent *some* `NaN` errors, because you cannot add a number to an object, for example. But there are many math operations that can return `NaN`. These `NaN` values often propagate through the code silently and crash in some random place that was expecting an integer or a float. It can be extremely difficult to backtrack through the code and try to figure out where the `NaN` came from. I would like TypeScript to provide a better way of preventing runtime

Comments (0)

No comments yet. Start the discussion.

Comment on this issue