ts-bindgen automatically produces rust wasm-bindgen bindings for typescript definitions. Read on to learn more or play around generating some bindings for typescript in your browser here.

Creating reasonable rust interfaces for typescript modules requires quite a bit of wrapping, ceremony, and manual work once you've decided on an acceptable pattern to work around the limitations of the wasm/js bridge. ts-bindgen attempts to produce relatively ergonomic rust interfaces for arbitrary typescript definitions.

First, a quick disclaimer: this is an early release of alpha software so you are likely to run into bugs. That means there are likely typescript definitions out there that will cause ts-bindgen to fail or to produce bad bindings. Report any issues you see and we'll do our best to address them quickly (and of course, we welcome contributions!).

Getting started

The quickest way to play around with ts-bindgen is to open up our web interface and paste in some typescript definitions (like you might find in a .d.ts file).

To start using ts-bindgen in your own projects, you'll want to

  1. Get your typescript definitions on your local machine (this likely means setting up a package.json and running an npm install)
  2. Install ts-bindgen with: cargo install --version 0.4.0 --bins ts-bindgen
  3. Generate your bindings! ts-bindgen --output src/bindings.rs your-ts-module

What to expect


  • Bindings for typescript classes are newtype wrappers around wasm-bindgen structs with a reasonable rust wrapper for each method.

  • Class wrappers implement traits for base classes and interfaces.

  • And...

    • Class wrappers implement serde serialization to/from JsValues supporting all js types, including functions.

    • Inline interfaces and other typescript types are raised to named rust types.


  • Interfaces generate structs with owned fields that implement serde serialization to/from JsValues. js-sys and web-sys types are properly handled.

  • Typescript utility types get reasonable representations.


  1. Overloaded functions generate individual rust wrapper functions with ergonomic parameters and return types.

What's next?

We have a lot more work to do on stability, better code generation, and performance (generation and runtime). Generated interfaces are still likely to change significantly. Join the mailing list below to stay up to date with our progress or drop us a line!