Skip to content

Issue an error when numeric literals can incur precision loss #29863

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

In JavaScript, you can write out a really really big (non-bigint) integer literal and get a completely different value.

0x6A09E667F3BCC908n == 0x6A09E667F3BCC908n // true

0x6A09E667F3BCC908n == 0x6A09E667F3BCC908  // false!?

It's worth asking whether or not a really really big integer values which have different observed and specified values are erroneous, and whether we can give users an error.

This would be a breaking change, but it's not clear who benefits from the current behavior.

See tc39/proposal-bigint#170 for where this came up (CC @littledan)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions