Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support (optional) bigint during parsing #95

Open
neko-para opened this issue Nov 28, 2024 · 0 comments
Open

Feature request: Support (optional) bigint during parsing #95

neko-para opened this issue Nov 28, 2024 · 0 comments

Comments

@neko-para
Copy link

Currently, number literal will be parsed by the following code:

case SyntaxKind.NumericLiteral:
const tokenValue = _scanner.getTokenValue();
let value = Number(tokenValue);
if (isNaN(value)) {

It would be better to add a feature that allow detecting the number and parsing it with BigInt, like:

// -9007199254740991 ~ 9007199254740991
// More precise checking could be used, here's only a demo
if (/^-?\d{16,}$/.test(tokenValue)) {
  value = BigInt(tokenValue)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant