| Crates.io | facet-typescript |
| lib.rs | facet-typescript |
| version | 0.43.2 |
| created_at | 2025-12-31 12:33:40.482421+00 |
| updated_at | 2026-01-23 18:06:31.665878+00 |
| description | Generate TypeScript type definitions from facet type metadata |
| homepage | https://facet.rs |
| repository | https://github.com/facet-rs/facet |
| max_upload_size | |
| id | 2014616 |
| size | 67,426 |
Generate TypeScript type definitions from facet type metadata.
This crate uses facet's reflection capabilities to generate TypeScript interfaces
and types from any type that implements Facet. Unlike going through JSON Schema,
this generates TypeScript directly, preserving:
readonly modifiersuse facet::Facet;
use facet_typescript::to_typescript;
#[derive(Facet)]
struct User {
name: String,
age: u32,
email: Option<String>,
}
let ts = to_typescript::<User>();
println!("{}", ts);
export interface User {
name: string;
age: number;
email?: string;
}
Generate types for multiple related types at once:
use facet_typescript::TypeScriptGenerator;
let mut gen = TypeScriptGenerator::new();
gen.add_type::<User>();
gen.add_type::<Post>();
gen.add_type::<Comment>();
let ts = gen.finish();
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
The facet logo was drawn by Misiasart.
Licensed under either of:
at your option.