ts-rs 1.0.1

generate typescript bindings from rust types
Documentation

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 trait 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.