Build Bulletproof TypeScript API Clients from OpenAPI with Zod — A Practical Guide
Surprising fact: even with TypeScript, production bugs caused by invalid API responses remain common — teams that add runtime validation report up to a 3x faster mean‑time‑to‑detect for contract mismatches. If you generate TypeScript client OpenAPI types but skip runtime checks, you’re leaving a large class of failures invisible until production. Why runtime validation still matters in TypeScript TypeScript's static types are great for developer ergonomics, but they are erased at runtime. Common pitfalls with generated types: Server drift: APIs evolve and clients can receive fields that don't match the generated type. Nullable vs missing: OpenAPI's nullable , readOnly and writeOnly semantics often differ from TypeScript expectations. Polymorphism (oneOf/anyOf/discriminator) is typed but not checked, leading to runtime narrowing errors. Slash TypeScript Build Times in Monorepos: Practical Guide to Incremental Compilation & Caching Zod adoptio...