Skip to content

Transform BigInt syntax into BigInt calls (12n --> BigInt(12)) #4049

@cyan-2048

Description

@cyan-2048

currently when using BigInt and having the target environment to be es6 you get this error
Image

however no errors occur when you do BigInt(0)

this is actually what some libraries do to test BigInt support, although sometimes for some reason some test BigInt by using the syntax (weird? maybe they weren't informed that using newer syntax on older environments results to everything else in the code not working)

slight suggestion: add a warning if this transform happens as this will still create errors when using on environments where BigInt does not exist

another suggestion: when the BigInt can be represented as a normal JS number (1, 2, anything less than the Number.MAX_SAFE_INTEGER) transform it to BigInt(n) else wrap it in a string BigInt("n")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions