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

About BigInt's browser compatibility #39

Closed
HaydenOrz opened this issue Feb 21, 2024 · 4 comments
Closed

About BigInt's browser compatibility #39

HaydenOrz opened this issue Feb 21, 2024 · 4 comments

Comments

@HaydenOrz
Copy link
Contributor

I noticed that antlr4ng uses BigInts. BigInts require ES2020.

BigInts are not lowered to older syntax in esbuild evanw/esbuild#732 . If I set esbuild's target option to be lower than es2020, then esbuild throws an exception about not being able to convert bigint. Babel also has a similar issue .

Whether to consider replacing Bigint and BigUint64Array with number and Uint16Array.

This has the potential to affect the performance of antlr4ng, and in general the long type in java should indeed correspond to the javascript Bigint and BigUint64Array (since both are 64-bit). But there is currently no good solution to the compatibility problem.

@mike-lischke
Copy link
Owner

mike-lischke commented Feb 21, 2024

Yes, that's true. In fact I don't write any TS code that requires ES earlier than 2022 (though 2020 would probably work too). All relevant browsers and Node.js support that. We should not support old technology forever in new code.

Bigint is, however, only used in the BitSet class, which is something that could be changed to use uint32.

@HaydenOrz
Copy link
Contributor Author

I can create a new PR to change it if you need to.

@mike-lischke
Copy link
Owner

Sure, why not! PR is welcome.

@mike-lischke
Copy link
Owner

PR is merged

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

2 participants