Tsify-next
Generate TypeScript definitions from Rust types via a derive macro
Repository Health
Technical Analysis
Tsify-next is a Rust library that generates TypeScript type definitions directly from your Rust types. By adding a #[derive(Tsify)] macro (alongside Serde’s derives), your structs and enums are emitted as matching TypeScript interfaces and types, and when combined with wasm-bindgen the definitions are written automatically into the generated .d.ts file.
It is a maintained continuation of the original Tsify project, keeping the derive-based, Serde-aware approach for bridging Rust and TypeScript in WebAssembly projects. (Note: the upstream Tsify has since caught up, and the authors now recommend it.)
What You Get
- A
#[derive(Tsify)]macro that maps Rust structs and enums to TypeScript types - Automatic
.d.tsoutput when used with wasm-bindgen - Serde-aware serialization semantics (rename, tag, and enum representations)
into_wasm_abi/from_wasm_abiattributes for passing typed values across the boundary- Support for generics, optional fields, and common Rust type mappings
Common Use Cases
- Exposing a Rust/wasm library to a TypeScript frontend with correct types
- Keeping TypeScript definitions in sync with Rust data models automatically
- Passing complex structs and enums between Rust and JS type-safely
- Replacing hand-maintained
.d.tsfiles for wasm-bindgen projects
Under The Hood
Architecture - The crate is a two-part workspace: the root tsify-next crate provides the Tsify trait and runtime glue, while tsify-next-macros implements the procedural derive macro. The macro parses the Rust type with syn, reads Serde container/field attributes to match serialization behavior, builds a TypeScript type declaration, and integrates with wasm-bindgen so the string is embedded into the emitted .d.ts.
Tech Stack - Rust proc-macro tooling (syn, quote, proc-macro2), integrating with serde and wasm-bindgen; end-to-end tests live under tests-e2e with reference output snapshots.
Code Quality - The repo maintains unit tests plus e2e reference-output tests that compile Rust and diff the generated TypeScript, giving strong confidence that macro output stays correct across changes.
API Design - The API is a single derive plus a small set of #[tsify(...)] attributes, so it feels familiar to anyone using Serde derives; the main learning curve is understanding how Serde’s representation choices translate into the emitted TypeScript.