Skip to main content

ts_typegen/
lib.rs

1//! Marker derive for types that should have TypeScript bindings generated.
2//!
3//! Generation itself happens in a build script via the `ts-typegen-build` crate.
4//! This derive expands to nothing; it exists so that `#[ts(...)]` is legal syntax
5//! and so the build-time scanner has a marker to look for.
6//!
7//! Pair it with `#[derive(Serialize)]`, since bindings describe the JSON
8//! serde actually writes:
9//!
10//! ```
11//! use serde::Serialize;
12//! use ts_typegen::Ts;
13//!
14//! #[derive(Serialize, Ts)]
15//! #[serde(rename_all = "camelCase")]
16//! struct User {
17//!     user_id: u64,
18//!     name: String,
19//!     #[serde(skip)]
20//!     secret: String,
21//! }
22//! ```
23//!
24//! `#[ts(...)]` is the escape hatch for anything serde's shape doesn't
25//! capture on its own — see the crate README for the full attribute list.
26#![forbid(unsafe_code)]
27
28pub use ts_typegen_macros::Ts;
29
30#[cfg(feature = "strict")]
31mod marker;
32#[cfg(feature = "strict")]
33pub use marker::TsType;