Skip to Content

typia

typia is a transformer that generates runtime validators, JSON serializers, Protocol Buffer codecs, random-data generators, and LLM function-calling schemas from your TypeScript types, at build time, with no manual schema work.

It is the canonical third-party ttsc plugin: same protocol, same compilerOptions.plugins[] wiring, same in-source AST transform pass.

Install

npm install -D ttsc typescript@rc typia

That’s it. typia ships the ttsc.plugin auto-discovery marker in its package.json, so ttsc picks it up the moment you list it in dependencies / devDependencies, no compilerOptions.plugins[] entry needed.

Run ttsc --emit (or any ttsc / ttsx / unplugin bundler that runs ttsc plugins). On every build, typia.* calls in your code are replaced with optimized, type-aware generated functions.

What it does

A typical typia call before transform:

import typia from "typia"; interface User { id: string & typia.tags.Format<"uuid">; email: string & typia.tags.Format<"email">; age: number & typia.tags.Type<"uint32"> & typia.tags.Maximum<150>; } export const validateUser = typia.createValidate<User>();

After ttsc, validateUser becomes a hand-rolled validator that checks every property against the type contract, no zod/joi/yup schema duplication, no runtime reflection.

The same shape covers:

  • Validation: typia.assert<T>(input), typia.is<T>(input), typia.validate<T>(input).
  • JSON: typia.json.stringify<T>(value) (5-20Γ— faster than JSON.stringify), typia.json.assertParse<T>(text).
  • Protocol Buffer: typia.protobuf.encode<T>(value), typia.protobuf.decode<T>(bytes).
  • Random: typia.random<T>() produces a fixture matching the type’s tags and constraints.
  • LLM: typia.llm.application<App>() generates an OpenAI / Claude / Gemini function-calling schema for every method of an interface.

Every transform reads the actual TypeScript type. There is no separate schema file to drift.

Why ttsc

typia is a TypeScript compiler transformer. Stock tsc does not run user transformers; ttsc is one of the supported hosts (along with ts-patch). On the ttsc side, typia is auto-discovered from package.json (no compilerOptions.plugins[] entry needed), ttsc resolves the package, builds and caches typia’s compiled sidecar, and routes the TypeScript-Go AST through it before emit.

typia works in every place ttsc runs:

  • ttsc --emit for build,
  • ttsx ./src/main.ts for typed execution,
  • every @ttsc/unplugin bundler adapter (Vite, Webpack, esbuild, Rollup, Rspack).

One install; the transform runs anywhere ttsc owns compilation. VS Code uses the same project config for TypeScript-Go and supported plugin diagnostics/actions, but editor integration does not rewrite emit.

Combine with other ttsc plugins

typia composes with @ttsc/lint, @ttsc/banner, @ttsc/paths, and @ttsc/strip in the same compilerOptions.plugins[] array. Lint runs before emit; linked transforms (banner, paths, strip) ride inside the selected compiler host. Two independent executable transform hosts cannot share one emit pass, if you need typia and another executable transformer together, see the composes field in Plugin protocol β†’ Combining plugins from different vendors.

Reference

typia ships on its own release schedule with its own docs and a deep API surface. Use this page for β€œhow does it slot into ttsc?” only.

See also

Last updated on