[−][src]Crate ts_rs
Generate TypeScript interface/type declarations from rust structs.
why?
When building a web application in rust, data structures have to be shared between backend and frontend.
Using this library, you can easily generate TypeScript bindings to your rust structs & enums, so that you can keep your
types in one place.
ts-rs might also come in handy when working with webassembly.
how?
ts-rs exposes a single trait, TS
.
Using a derive macro, you can implement this interface for
your types.
Then, you can use this trait to obtain the TypeScript bindings.
We recommend doing this in your tests. see the example
serde compatibility layer
With the serde-compat
feature enabled, ts-rs tries parsing serde attributes.
Please note that not all serde attributes are supported yet.
Traits
TS | A type which can be represented in TypeScript. |
Derive Macros
TS | Derives TS for a struct or enum. Please take a look at TS for documentation. |