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

Support regular JS numbers for incoming 64-bit integers #4201

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RunDevelopment
Copy link
Contributor

@RunDevelopment RunDevelopment commented Oct 15, 2024

fixes #4113

This adds support for regular JS numbers (think typeof x === 'number') as values for u64 and i64 parameters. This should makes Rust APIs taking large numbers more convenient on the JS side and allows bindings for JS functions that return large numbers (e.g. Date.now()).

For details on the number -> bigint conversion, see the doc comment for number_to_bigint. Otherwise, the implementation of this PR is quite simple. The correctness of the conversion is tested in the optional_primitives test.

The reason this PR is still a draft is that I haven't updated the code for function signature types yet. E.g. arg: u64 is still arg: bigint in TS, even thought it should be arg: bigint | number now. I'm waiting for #4188, because #4188 add exactly the functionality I need to implement this.

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

Successfully merging this pull request may close these issues.

Can't return Number values as u64
1 participant