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

Can't use bigint literals or do arithmetic with es5 target #174

Closed
austinabell opened this issue Aug 10, 2022 · 1 comment · Fixed by #176
Closed

Can't use bigint literals or do arithmetic with es5 target #174

austinabell opened this issue Aug 10, 2022 · 1 comment · Fixed by #176
Labels
bug Something isn't working

Comments

@austinabell
Copy link
Contributor

austinabell commented Aug 10, 2022

Currently, the CLI statically targets es5 for compiling contracts, but this makes certain things within the SDK hard to do like performing arithmetic on the values returned from the API (I don't know if another target fixes this) or using bigint literals (like 100n to signify a big int).

I don't even know what the recommended way to perform a simple action like:

near.prepaidGas() - 5000000

The closest thing I could find would be:

Number(near.prepaidGas()) - 5000000

but this is absolutely horrible because on overflow it just cuts off bits and doesn't error. Casting the BigInt to any or casting the right operand to BigInt seems to throw an error

@ailisp
Copy link
Member

ailisp commented Aug 11, 2022

It seems that we should use es2020 for compiling target, as bigint is in es2020 and quickjs support that. I'll check typescript decorator still works under that setting.

@ailisp ailisp added the bug Something isn't working label Aug 11, 2022
@volovyks volovyks linked a pull request Aug 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants