-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Champion: @littledan
Spec Repo: https://github.com/tc39/proposal-bigint
Spec Text: https://tc39.github.io/proposal-bigint
Slides (to Stage 3 at May TC39 Meeting): https://docs.google.com/presentation/d/1lrcjQzIFgdUXczeeAzs4GkTXJsRQU21UhtmXef70Qic/edit#slide=id.p
moved to Stage 3 at July TC39 Meeting https://github.com/tc39/agendas/blob/master/2017/07.md
The syntax has been implemented in Babylon, see babel/babylon#569 (comment) . What remains is a plugin to implement the transform.
- All arithmetic operations and comparisons should be replaced by calls to functions which provide the appropriate behavior depending whether arguments are BigInts or Numbers.
- The transform is slow, so it will really be more of a toy rather than something that should be used in production. For this reason, I'd argue it should be left out of Babel presets.
- Polyfill needed--ideally, this would be a thin wrapper around another BigNum library from npm. There are just a few methods to support. Some functions will have to be a bit different to get close to the right behavior, for example,
valueOf()should throw a TypeError, so that implicitly casting to Number throws a TypeError, even if it would really return the BigInt. Additionally, the polyfill needs BigInt64Array and DataView operations. - A good starting point from @amilajack:
I've done some work on this in a babel plugin that prevents coercion in JS. Here's the related code for that
Reactions are currently unavailable