-
Notifications
You must be signed in to change notification settings - Fork 117
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
large integer types should also be typed as numbers #94
Comments
Worth noting that wasm-bindgen converts u64 arguments/returns to BigInt due to the limitations of JS numbers and the WASM spec around larger integers |
It's worth noting that if you have a i64/u64/etc. and deserialize it to a number in javascript you may get subtle errors as a |
I understand that 64+-bit numbers are usually converted to bigint when sent to JS across the WASM boundary, but when serializing using eg So when using |
First, I understand the reasoning behind being dogmatic about u64 to bigint, and I can see it being the default. However, I think there are some valid use cases where it is acceptable to assume u64 as a JS number, as 2^53 can be practically unreachable for many use cases. Having something like a #[ts_as_number] would avoid unnecessary JSON/TS bigint gymnastic or be stuck below the u32 limit. 2022-09-08 - Apologies! I did not realize we could annotate a property with |
It would be nice if attributes could be added to deal with this, instead of manually annotating with Personally, I see the value in edit: yes I know |
Hey @NyxCode! What's your opinion on this whole issue? |
currently,
i64
,u64
,i128
, andu128
are defined to export tobigint
, such that:creates a TS declaration like:
However,
foo
may be anumber
instead of abigint
eg if usingJSON.parse
, so the interface should actually be:The text was updated successfully, but these errors were encountered: