ts-bindgen-gen   CI Latest Version Rust Documentation Crates.io

ts-bindgen-gen contains the typescript parsing and rust wasm-bindgen binding generation logic for ts-bindgen.

For usage information about ts-bindgen, check out the ts-bindgen docs, online playground, or repo.

Status

ts-bindgen is currently alpha software and it should be expected that any or all of the following might change significantly from version to version: 1. Generated bindings 2. Exposed interfaces 3. Internal implementation

There are currently known issues that will prevent generation of reasonable bindings for some typescript idioms.

We welcome contributions and issues!

Overview

The overall flow is: 1. Parse typescript from swcecmaast into our base ir 2. Transform our base ir into a flattened ir and then into a target-enriched ir. The flattened ir takes types that are inlined and unnamed in typescript (e.g. the implied number | string enum in interface { a: number | string }) and "flattens" them to named, top-level types while fixing up references. The target-enriched ir propagates file and namespace context down through the AST. 3. Construct a Module Definition hierarchy representing the rust modules and types in each module. 4. Generate our rust bindings by walking the ModDef hierarchy and generating a proc_macro2::TokenStream.

Todo

Needed refactorings

License

ts-bindgen is dual-licensed under the MIT and Apache licenses.

Credit

ts-bindgen is crafted thoughtfully by Ratchet Designs