export-type
A Rust proc-macro crate for automatically generating TypeScript type definitions from Rust structs and enums.
Features
- Export Rust structs and enums to TypeScript
- Support for generics
- Field renaming with
renameandrename_allattributes - Support for common Rust types:
- Basic types (numbers, strings, booleans)
- Collections (Vec, HashMap)
- Optional values (Option)
- Custom types
- Generates a single TypeScript file with all types
Installation
Add this to your Cargo.toml:
= { = "0.1.1", = true }
Usage
Use the #[export_type] attribute on structs and enums.
Example:
And you'll get a index.ts file in the specified path with the following contents:
export type MyStruct = {
field: string;
};
export type MyEnum = "Variant1" | "Variant2";