Support regular JS numbers for incoming 64-bit integers #4201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #4113
This adds support for regular JS numbers (think
typeof x === 'number'
) as values foru64
andi64
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 fornumber_to_bigint
. Otherwise, the implementation of this PR is quite simple. The correctness of the conversion is tested in theoptional_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 stillarg: bigint
in TS, even thought it should bearg: bigint | number
now. I'm waiting for #4188, because #4188 add exactly the functionality I need to implement this.