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.
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!
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.
this
parameters properlyCopyright 2022 Adam Berger, Ratchet Designs.
ts-bindgen is licensed under either of the MIT or Apache licenses, at your option.
ts-bindgen is crafted thoughtfully by Ratchet Designs