Back to directory

ts-rs

A Rust derive macro that generates matching TypeScript type declarations from Rust structs and enums, for keeping shared data types in sync between a Rust backend and a TypeScript frontend.

ts-rs

ts-rs exposes a TS trait that a derive macro implements for Rust structs and enums, generating TypeScript type declarations from them, including generic types and enum-to-union-type conversion, compatible with Serde. Running the project's tests, such as cargo test export_bindings, writes the generated TypeScript to a bindings directory as a side effect of the test.

Environment variables configure how and where bindings are exported: the output directory, the file extension used in generated import statements, and the binding used for large integer types such as i64 and u64. Bindings can also be exported programmatically, without running tests, through export_all, export and export_to_string.

A type without a TS implementation can be handled with a ts(as) or ts(type) attribute, or an appropriate cargo feature.

More in Libraries

See all 292
  • OpenDecision

    deepanwadhwa.github.io

    An open-source Python package that answers typed questions about application state or documents using a local natural-language-inference model, returning structured choice, score, yes/no or evidence-relation values instead of free text.

  • TradeCanvas

    bonguynvan.github.io

    A zero-dependency canvas charting engine for building TradingView-style trading charts in JavaScript, with 66 technical indicators, 24 drawing tools, 17 chart types, and real-time streaming.

  • 3d retro graphics

    3d-retro.com

    A free, CC0-licensed library of copy-paste retro 3D and demoscene graphics effects, such as plasma, raytracing, and voxel terrain, runnable as WebGL 1 or plain 2D canvas.