#[ts]Expand description
Generates TypeScript type aliases and wasm-bindgen ABI trait implementations
for Rust items.
This attribute can be applied to:
- Structs: Generates a TypeScript interface and property bindings.
- Enums: Automatically applies
#[wasm_bindgen](supports C-style enums). - Type Aliases: Generates a TypeScript type alias and a typed function wrapper.
- Impl Blocks: Generates a typed function wrapper for a
callmethod.
ยงExamples
Struct Usage
โ
#[ts(rename_all = "camelCase")]
struct MyStruct {
field_name: String,
}Enum Usage
โ
#[ts]
enum Status { Active, Inactive }Function Wrapper Usage
โ
#[ts]
pub type OnReady = fn(msg: String);
#[ts]
struct AppFunctions {
on_ready: OnReady,
}