Tsify-next

Generate TypeScript definitions from Rust types via a derive macro

Library
Cargo
v0.5.6
66stars
Apache-2.0 OR MIT

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
29/100Needs Attention
Development Activity4
Maintenance0
Community44
Maturity48
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture82
Code Quality80
Innovation80
Learning Curve74

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.ts output when used with wasm-bindgen
  • Serde-aware serialization semantics (rename, tag, and enum representations)
  • into_wasm_abi / from_wasm_abi attributes 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.ts files 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search