12 releases (4 breaking)
Uses new Rust 2024
| new 0.5.2 | Apr 11, 2026 |
|---|---|
| 0.5.0 | Apr 8, 2026 |
| 0.4.2 | Mar 29, 2026 |
| 0.3.1 | Mar 25, 2026 |
| 0.1.3 | Mar 14, 2026 |
#251 in Build Utils
Used in 2 crates
(via typewriter-engine)
83KB
2K
SLoC
typewriter-typescript
TypeScript emitter for the typewriter SDK.
What It Generates
For each Rust type targeting TypeScript, this crate generates:
<type>.tswith static TypeScript interfaces/types<type>.schema.tswith runtime Zod schemas
| Rust | TypeScript |
|---|---|
struct |
export interface + export const NameSchema = z.object(...) |
Simple enum |
String literal union + z.enum([...]) |
Tagged enum |
Discriminated union + z.discriminatedUnion(...) |
Option<T> |
field?: T | undefined + .optional() |
Vec<T> |
T[] + z.array(...) |
HashMap<K,V> |
Record<K, V> + z.record(...) |
Example Output
// user-profile.ts
export interface UserProfile {
id: string;
email: string;
age?: number | undefined;
tags: string[];
}
// user-profile.schema.ts
import { z } from 'zod';
export const UserProfileSchema = z.object({
"id": z.string(),
"email": z.string(),
"age": z.number().optional(),
"tags": z.array(z.string()),
});
Runtime Dependency
Generated schema files import from zod:
npm install zod
Usage
Used internally by typewriter-macros. Most users should depend on the main typewriter crate.
License
Apache-2.0 — Aarambh Dev Hub
Dependencies
~0.6–1.3MB
~28K SLoC