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

Feature request: serde-wasm-bindgen compatibility. #313

Open
lucasvanmol opened this issue Apr 23, 2024 · 5 comments
Open

Feature request: serde-wasm-bindgen compatibility. #313

lucasvanmol opened this issue Apr 23, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@lucasvanmol
Copy link

Is your feature request related to a problem? Please describe.
Currently, using serde-wasm-bindgen will generate : any types. It would be nice if ts-rs could integrate with this library to be able to generate proper types.

Describe the solution you'd like
serde-wasm-bindgen generates proper TS types based on #[derive(TS)], for example when a certain feature of ts-rs is enabled.

Describe alternatives you've considered
The serde-wasm-bindgen docs mention tsify, but it seems unmaintained.

@lucasvanmol lucasvanmol added the enhancement New feature or request label Apr 23, 2024
@lucasvanmol
Copy link
Author

@escritorio-gustavo
Copy link
Contributor

Hm, I have no experience with wasm-bindgen at all. Is there a minimal project you can point us to so we can see what ts-rs currently generates, as well as the desired output?

@escritorio-gustavo
Copy link
Contributor

escritorio-gustavo commented Apr 23, 2024

image
From what I see, it seems like this crate works by using #[serde(with = "...")]? If that is the case, currently you'd need to use #[ts(as = "...")] and point it to a type that exports the desired TS code

See #275 and #280 for the reasoning behind this

@fhilgers
Copy link

There is also tsify-next which is an actively maintained fork of tsify (https://crates.io/crates/tsify-next).

@NyxCode
Copy link
Collaborator

NyxCode commented Jun 21, 2024

I'm at a similar place as @gustavo-shigueo - I'd love to integrate (more) with wasm-bindgen, but my experience with it is very limited. The few times I used it I

  • used primitives as arguments/return types wherever possible
  • (de)serialized more complex types from/to JSON, just using &str or String as arguments/return types

For option 2), ts-rs would be perfect as-is. To do anything else, I'd need some time (or help!) to actually really understand the usecase.

What exactly should ts-rs add to integrate better with wasm-bindgen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants