Does TypeScript have a NaN type? [duplicate]












2
















This question already has an answer here:




  • Integer (literal) union type, with NaN as valid return value

    2 answers




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.










share|improve this question















marked as duplicate by R. Richards, ConnorsFan, Community Jan 1 at 23:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

    – Kyle
    Jan 1 at 23:39


















2
















This question already has an answer here:




  • Integer (literal) union type, with NaN as valid return value

    2 answers




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.










share|improve this question















marked as duplicate by R. Richards, ConnorsFan, Community Jan 1 at 23:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

    – Kyle
    Jan 1 at 23:39
















2












2








2









This question already has an answer here:




  • Integer (literal) union type, with NaN as valid return value

    2 answers




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.










share|improve this question

















This question already has an answer here:




  • Integer (literal) union type, with NaN as valid return value

    2 answers




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.





This question already has an answer here:




  • Integer (literal) union type, with NaN as valid return value

    2 answers








javascript node.js angular typescript types






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 2:25









Dale Burrell

3,25932553




3,25932553










asked Jan 1 at 23:18









KyleKyle

5415




5415




marked as duplicate by R. Richards, ConnorsFan, Community Jan 1 at 23:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by R. Richards, ConnorsFan, Community Jan 1 at 23:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

    – Kyle
    Jan 1 at 23:39
















  • 1





    Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

    – Kyle
    Jan 1 at 23:39










1




1





Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

– Kyle
Jan 1 at 23:39







Definitely a duplicate but I couldn't find that so I'll leave my question. Thanks for your comment! I liked the explanation on that question

– Kyle
Jan 1 at 23:39














1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer
























  • Oh cool! I definitely want to see this feature, thank you

    – Kyle
    Jan 1 at 23:33


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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.






share|improve this answer
























  • Oh cool! I definitely want to see this feature, thank you

    – Kyle
    Jan 1 at 23:33
















1














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.






share|improve this answer
























  • Oh cool! I definitely want to see this feature, thank you

    – Kyle
    Jan 1 at 23:33














1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 1 at 23:22









Titian Cernicova-DragomirTitian Cernicova-Dragomir

68.1k34764




68.1k34764













  • Oh cool! I definitely want to see this feature, thank you

    – Kyle
    Jan 1 at 23:33



















  • Oh cool! I definitely want to see this feature, thank you

    – Kyle
    Jan 1 at 23:33

















Oh cool! I definitely want to see this feature, thank you

– Kyle
Jan 1 at 23:33





Oh cool! I definitely want to see this feature, thank you

– Kyle
Jan 1 at 23:33





Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas