Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Typescript uses 'number' instead of int'? [duplicate]

I'm quite familiar with the framework, I love it since inception.

One thing that I haven't fully been able to grasp is why the Typing was sometimes off.

Specifically for this question, number, I'm not sure why the int wasn't used, at first I thought it might be the discrepancy of behavior between int32 / int16 / float etc.. But that doesn't make sense (to me) in transpilation.

So from the lib it needs to play nice with Math.

My question is really about semantics, why was the decision made to use number and not int ?

like image 764
Pogrindis Avatar asked Dec 06 '25 04:12

Pogrindis


1 Answers

Because that is what JavaScript uses.

Example

console.log(typeof 123); // 'number'
like image 63
basarat Avatar answered Dec 07 '25 18:12

basarat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!