-
Notifications
You must be signed in to change notification settings - Fork 119
Deriving the TS trait
The TS
trait can be easily derived through its #[derive(TS)]
macro,
which will automatically handle mapping a Rust type into TypeScript type
definitions.
The #[derive(TS)]
macro provides an attribute helper macro called #[ts(...)]
which can help you control how the types will be generated
These are attributes that can be used both with structs and enums
This attribute causes the generation of a test which will create a ts file containing the TypeScript declaration for your type
Allows you to change where your TypeScript file will be generated (default is
./bindings/TypeName.ts
).
This must be either:
- An absolute path
- A path relative to your crate's
Cargo.toml
The given path will be treated as a directory if it ends with a /
character, in which case a file called TypeName.ts
will be created
within the given directory, otherwise the path will be treated as a
file (even without an extension).