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 serde-wasm-bindgen #100

Open
stefnotch opened this issue Apr 15, 2023 · 3 comments
Open

Support serde-wasm-bindgen #100

stefnotch opened this issue Apr 15, 2023 · 3 comments

Comments

@stefnotch
Copy link

stefnotch commented Apr 15, 2023

When using Rust together with Javascript, one common way of doing so is by using wasm-bindgen.

However, wasm-bindgen does not recommend using the default serde approach for converting Rust to Javascript. Instead they recommend using serde-wasm-bindgen. This is also the first recommended approach in their documentation.

The problem is that serde-wasm-bindgen does a few things rather differently. For example, Rust HashMaps are turned into Javascript Maps This, of course, doesn't line up with what the typeshare crate offers.

Sadly the lovely developers of serde-wasm-bindgen have deemed generating Typescript as "out of scope", hence I'm opening an issue here.
I wanted to ask if it would be in-scope to support that use-case? Or if I should raise an issue elsewhere.

For completeness sake, there's a smaller, less maintained crate that seems to be able to generate the correct types when using serde-wasm-bindgen https://github.com/madonoharu/tsify

@sanjanadesai27
Copy link

Thanks for submitting this issue. Right now this is out of scope but we are aiming to provide support for wasm targets in the future.

@stefnotch
Copy link
Author

Thanks for the clear response! Then I'll look forward to what you'll do in the future, and for now either

  • use the default Serde JSON approach together with this library
  • or maintain Typescript types by hand

And for the future, I'll

@RReverser
Copy link

Then I'll look forward to what you'll do in the future, and for now either

  • use the default Serde JSON approach together with this library
  • or maintain Typescript types by hand

FWIW you (and anyone else coming across this issue) might want to look into tsify which supports generating TS defintiions and works in conjunction with serde-wasm-bindgen.

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

No branches or pull requests

3 participants