You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposal adds a new syntax for integer literals:
42n // This is an integer literal
Implicit conversions to/from numbers and integers and expressions with mixed operands are expressly disallowed:
42n + 1 // Throws TypeError
Type constructors are provided that wrap at specified widths:
Integer.asUintN(width, Integer): Wrap an Integer between 0 and 2**width-1
Integer.asIntN(width, Integer): Wrap an Integer between -2**(width-1) and 2**(width-1)-1
Integer.parseInt(string[, radix]): Analogous to Number.parseInt, to parse an Integer from a String in any base.
Though not stated in the spec, these constructors should theoretically hint to the VM when it's possible to use a native 64-bit integer type instead of a bignum, and could therefore possibly be used by TypeScript to implement int64 and uint64 types in addition to e.g. an integer type of arbitrary precision.
I know people have been asking for integers for quite some time (e.g. #195, #4639), but have been held back by lack of native support of an integer type in JavaScript itself. Now it seems this proposal is stage 2 (scratch that, stage 3!) and has multi-browser vendor backing, so perhaps the prerequisites are finally in place to make integers happen.
clavecoder, Bnaya, kikar, styfle, pocesar and 60 moretarcieri, Cixelyn, Bnaya, styfle, samrg472 and 12 moretarcieri, samrg472, cyphercider, j-oliveras, x-strong and 11 more