BigInt downleveling/polyfilling/transpiling — integrate with JSBI? #28756
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
Too Complex
An issue which adding support for may be too complex for the value it adds
Search Terms
bigint
Suggestion
I was excited to see
BigInt
support in TypeScript 3.2 ♥ I also read the relevant announcement, and this part caught my eye: https://blogs.msdn.microsoft.com/typescript/2018/11/29/announcing-typescript-3-2/#bigintWe very recently launched the JSBI library which serves as a spec-compliant BigInt polyfill. So recently in fact, I imagine it may not yet have been considered by the TypeScript team. (It it was, and you already decided against it, then please feel free to close this issue immediately!)
Here’s the thing: instead of native BigInt code, TypeScript could choose to produce JSBI code for the
es2017
target and below. That would enable TypeScript users to write BigInt code and have it be transpiled conditionally depending on their configuredtarget
.I believe this might be possible because unlike Babel, TypeScript actually knows which variables represent BigInts instead of other types. Therefore, it seems TypeScript could avoid wrapping every single operator in a function call — it would only do so for operations that TypeScript know involve a BigInt.
Please correct me if I’m wrong and feel free to close this issue if my assumptions don’t make sense.
Use Cases
BigInt functionality is currently only available when targeting
esnext
. Outputting JSBI for thees2017
target and older would at least enable the functionality in current/older environments other than recent versions of Chrome and Node.js.Examples
Native BigInt code:
Equivalent JSBI code (works in all modern browsers):
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: