wasm-bindgen is a Rust library and CLI toolchain that facilitates high-level interoperability between Rust-generated WebAssembly modules and JavaScript. It provides a `#[wasm_bindgen]` procedural macro to import JS functions and export Rust functions/structs/enums to JS, along with a post-processing CLI (`wasm-bindgen`) that generates JavaScript and TypeScript glue code for multiple targets (bundler, web, Node.js, Deno, no-modules). The repository also includes runtime crates (`js-sys`, `web-sys`, `wasm-bindgen-futures`, `wasm-bindgen-test`) that offer comprehensive bindings to standard JavaScript APIs and browser Web APIs, generated from WebIDL definitions. The project is the de facto standard for Rust-to-Wasm development, with extensive examples, benchmarks, and a robust test suite covering browser, Node, Deno, and headless environments.
tsify is a Rust library that generates TypeScript type declarations from Rust types, primarily for the wasm-bindgen ecosystem. The core mechanism is a `#[derive(Tsify)]` proc macro that produces a `Tsify` trait impl whose `DECL` constant is emitted into the wasm-bindgen `typescript_custom_section`, so `wasm-pack` automatically appends the generated `.d.ts` alongside the JS output. It maps Rust structs, enums, and type aliases to TypeScript interfaces, type aliases, namespaces, and unions, respecting serde attributes (`rename`, `tag`, `untagged`, `flatten`, `skip`, `default`, `transparent`) and offering tsify-specific overrides (`type`, `type_params`, `type_prefix`/`type_suffix`, `rename`, `namespace`, and serializer options like `missing_as_null` / `hashmap_as_object` / `large_number_types_as_bigints`). A second runtime type, `Ts<T>`, provides a memory-safe alternative to the deprecated `into_wasm_abi`/`from_wasm_abi` attributes by deferring deserialization out of the infallible ABI boundary into the function body, avoiding the destructor-skipping `throw_str` leak path.