Does TypeScript have a NaN type that I could declare for a variable?
For example, if I was to create a variable like this:
const number: number = parseInt('123', 10);
Could I change it to be more accurate, like so:
const number: number | NaN = parseInt('123', 10);
Basically I want to know if I can declare a variable as a NaN type (not undefined or null). The above snippet doesn't work in TypeScript and I can't find it listed in either the Basic or Advanced Types within TypeScript's guides.
There is no NaN
type in Typescript. There is a proposal for this on GitHub but there is no timeline for implementation. Consider upvoting the issue if you want to see this feature in Typescript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With