-
Notifications
You must be signed in to change notification settings - Fork 101
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
Are usize
and i64
not supported?
#24
Comments
as with |
Thanks for opening this issue. I'll look into whether this is possible. |
Getting a similar error with typeshare/core/src/rust_types.rs Lines 225 to 227 in fbf5aea
But the types exist in the SpecialRustType and looking in the four supported languages, they all have mappings for those four types. Locally I've changed those three lines in ChangesIn - "u64" | "i64" | "usize" | "isize" => {
- return Err(RustTypeParseError::UnsupportedType(vec![id]))
- }
+ "u64" => RustType::Special(SpecialRustType::U64),
+ "usize" => RustType::Special(SpecialRustType::USize),
+ "i64" => RustType::Special(SpecialRustType::I64),
+ "isize" => RustType::Special(SpecialRustType::ISize), and in SpecialRustType::U64
| SpecialRustType::I64
| SpecialRustType::ISize
| SpecialRustType::USize => {
- panic!("64 bit types not allowed in Typeshare")
+ Ok("number".into())
}
|
I think part of the problem is that JSON is usually going to be the medium of exchange for typeshared data, and so when you're loading into javascript / typescript you'd need to not use |
I understand that most people would use JSON (as it is one of the most popular transport medium), but it is not the only transport medium in which If users of |
Since typeshare is a developer tool, I would recommend picking a default (failing or bigint are both reasonable) and letting the developer override it by property. In many circumstances, 2^53-1 or 2^64-1 can be considered equivalent (v.s. the complexity of introducing bigint in all JS code base). Obviously, this should not be the default, but not providing this escape hatch might add unnecessary code complexity downstream. |
I just ran into this -- I also need to serialize u64 types. Seems like an oversight to always panic when encountering these types as there are types in the destination languages to support large numbers. At least let the developer set the type themselves. |
@mattyg A workaround for this is to use |
This workaround doesn't work. Tested stable and the beta branch. |
I think it would make sense for us to support these and emit a suppressable warning if they are used. @Lucretiel |
@LuminaSapphira I made a PR for supporting this about a year back. What do you think of that approach (i.e. allow only if the output type is explicitly specified?) |
I resolved the existing merge conflicts in the above PR. I would still really appreciate a review + workflow approval from a maintainer! |
Ran typeshare on my project and got the following errors:
i64 can be represented using a JS BigInt.
The text was updated successfully, but these errors were encountered: