cd /news/developer-tools/should-typescript-support-runtime-ty… · home topics developer-tools article
[ARTICLE · art-137318] src=twitter.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Should TypeScript support runtime types instead of relying on Zod?

A developer is proposing that TypeScript add an optional compiler flag to preserve enough type information to generate JSON Schema at runtime, eliminating the need to duplicate native TypeScript types in Zod or JSON Schema for structured output. The developer argues the duplication wastes tokens whenever both a type definition and its schema are sent to a model, and notes coding agents like Claude and Codex often generate unit tests just to verify the conversion is correct. The proposal is illustrated with a small playground showing a TypeScript type flowing through the compiler to a runtime JSON Schema.

read1 min views1 publishedSep 22, 2026
Should TypeScript support runtime types instead of relying on Zod?
Image: source

I like TypeScript almost as much as I like C# (phew, almost 20 years together). One thing that has always been both useful and painful is the lack of runtime types. On one hand, it's great that TypeScript types disappear at runtime and don't increase the bundle size. On the other hand, we're entering a phase where structured output is becoming much more common. Having to duplicate your native TypeScript types in Zod, JSON Schema, or another schema library starts to feel painful. Especially from the token-count perspective: every time you send both your type definition and its duplicated schema to a model, you're basically describing the same structure twice. And I'm not even counting the unit tests that Claude, Codex, and other coding agents often generate just to verify that the conversion is correct. So why doesn't TypeScript offer an optional compiler flag that preserves enough type information to generate JSON Schema at runtime? Something like: TypeScript type → compiler → runtime JSON Schema I made a small playground showing roughly how I imagine this could work:

── more in #developer-tools 4 stories · sorted by recency
── more on @typescript 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/should-typescript-su…] indexed:0 read:1min 2026-09-22 ·