Aleph-Alpha/ts-rs

Feature request: `serde-wasm-bindgen` compatibility.

lucasvanmol opened this issue · 5 comments

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.

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?

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

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

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?