Skip to content

BigInt (Stage 3) #2

Open
Open

Description

@littledan

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

Activity

  1. wdhorton commented on Jun 29, 2017

    @wdhorton

    Now that the syntax has been implemented, I can go ahead and work on the transform too

  2. littledan commented on Jul 12, 2017

    @littledan
    Author

    How's this implementation coming along? Anything I could help with?

    BTW there are some tests to start with in test262 here from my colleague @cxielarko at Igalia, but there's a lot of room for additional tests.

  3. changed the title [-]Implement the BigInt proposal[/-] [+]BigInt (Stage 2)[/+] on Jul 17, 2017
  4. wdhorton commented on Jul 26, 2017

    @wdhorton

    @littledan apologies for the delay on this, haven't had as much time to work on it as I expected. i'm planning on digging in this weekend and hopefully getting through a lot of it, and i just put up a WIP PR with the transform for adding BigInts, with a few questions babel/babel#6015

  5. changed the title [-]BigInt (Stage 2)[/-] [+]BigInt (Stage 3)[/+] on Jul 27, 2017
  6. towc commented on May 4, 2018

    @towc

    any developments on this? Somewhere you might want help?

  7. graup commented on Oct 24, 2018

    @graup

    There's a PR with some progress in babel/babel#6015. I'd also love to see this working, as Chrome has built-in support for bigints now (https://developers.google.com/web/updates/2018/05/bigint), so it would make sense to start writing code with the new syntax.

  8. littledan commented on Oct 24, 2018

    @littledan
    Author

    Seems like this would be a good project for someone to pick up.

  9. Bnaya commented on Nov 9, 2018

    @Bnaya

    FYI: typescript have merged their BigInt support!
    microsoft/TypeScript#25886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions