Skip to content

Using BigInt primitives #6907

Open
Open
@benfletcher

Description

@benfletcher

Is this a bug report?

No

Did you try recovering your dependencies?

n/a

Which terms did you search for in User Guide?

bigint, babel plugin,babel syntax macro, "Identifier directly after number"

Environment

n/a

Steps to Reproduce

(Write your steps here:)

  1. Use a BigInt primitive, e.g., 42n
  2. Define supported browsers in package.json to be last 1 chrome version. I.e., ignore targets that haven't implemented BigInts yet.

Expected Desired Behavior

A way to use BigInt primitives in CRA without ejecting.

BigInt (Spec) is currently at Stage 4, with support in Node (since 10.4) and all major desktop and mobile browsers Caniuse details.

Side note: You can get partial support by declaring the global (/* global BigInt */) if each BigInt is wrapped (BigInt(42) or BigInt('42')). However this still means that a code rewrite will be needed once full support lands to remove the clunky syntax.

Actual Behavior

Syntax error:

Identifier directly after number

Reproducible Demo

const foo = 42n;

(Edited to reflect this proposal has moved to Stage 4 and has additional browser support and removed reference to the Babel plugin which is no longer necessary.)

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