Expand description
Marker derive for types that should have TypeScript bindings generated.
Generation itself happens in a build script via the ts-typegen-build crate.
This derive expands to nothing; it exists so that #[ts(...)] is legal syntax
and so the build-time scanner has a marker to look for.
Pair it with #[derive(Serialize)], since bindings describe the JSON
serde actually writes:
use serde::Serialize;
use ts_typegen::Ts;
#[derive(Serialize, Ts)]
#[serde(rename_all = "camelCase")]
struct User {
user_id: u64,
name: String,
#[serde(skip)]
secret: String,
}#[ts(...)] is the escape hatch for anything serde’s shape doesn’t
capture on its own — see the crate README for the full attribute list.
Traits§
- TsType
- Marks a type as having a known TypeScript binding. Implemented for every
type the lowering pipeline understands; a field whose type has no impl
fails to compile instead of silently emitting
unknown.
Derive Macros§
- Ts
- The
Tsderive macro. See the crate-level docs for what it does.