#typescript #codegen #interface #type-sync

build typewriter-typescript

TypeScript emitter for the typewriter type sync SDK

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)

Apache-2.0

83KB
2K SLoC

typewriter-typescript

TypeScript emitter for the typewriter SDK.

Crates.io Docs.rs

What It Generates

For each Rust type targeting TypeScript, this crate generates:

  • <type>.ts with static TypeScript interfaces/types
  • <type>.schema.ts with 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