generating-theme-types.md

 1[⬅ Back to Index](../index.md)
 2
 3# Generating Theme Types
 4
 5
 6## How to generate theme types:
 7
 8Run a script
 9
10```bash
11./script/build-theme-types
12```
13
14Types are generated in `styles/src/types/zed.ts`
15
16
17## How it works:
18
191. Rust types
20
21    The `crates/theme` contains theme types.
22    Crate `schemars` used to generate a JSON schema from the theme structs.
23    Every struct that represent theme type has a `#[derive(JsonSchema)]` attribute.
24
25    Task lotaked at `crates/xtask/src/main.rs` generates a JSON schema from the theme structs.
26
272. TypeScript types
28
29    Script `npm run build-types` from `styles` package generates TypeScript types from the JSON schema and saves them to `styles/src/types/zed.ts`.