Skip to Content
📖 Guide Documents📦 SetupCurrent (TypeScript 7)

Setup

typia is a compile-time transformer, so your build has to run through the TypeScript 7 transformer path. Install typia, typescript, and ttsc; then build with ttsc or execute TypeScript directly with ttsx.

Note

Projects pinned to typia 12 and TypeScript below 7 use the legacy TypeScript setup. The rest of this page is the current typia 13 and TypeScript 7 setup.

Important

typia’s native transform requires ttsc 0.19.2 or newer. On an older ttsc the transform fails to build.

Install

Terminal
npm i typia npm i -D ttsc typescript

Keep the TypeScript project strict:

tsconfig.json
{ "compilerOptions": { "strict": true } }

Build

Use ttsc where you would normally run a TypeScript compiler:

Terminal
npx ttsc npx ttsc --noEmit npx ttsc --watch

Execute Without Building

Use ttsx instead of runners that strip TypeScript before typia can transform it:

Terminal
npx ttsx src/index.ts
Important

The stock tsc, ts-node, and tsx commands do not load typia’s transform. Use ttsc, ttsx, or @ttsc/unplugin.

Bundlers

Bundlers such as Vite, Next.js, Rollup, esbuild, Webpack, Rspack, Farm, and Bun run their own TypeScript pipeline. Install @ttsc/unplugin and add the matching plugin to the bundler config.

Terminal
npm i -D @ttsc/unplugin
vite.config.ts
import ttsc from "@ttsc/unplugin/vite"; import { defineConfig } from "vite"; export default defineConfig({ plugins: [ttsc()], });

If the bundler should use a config other than tsconfig.json, pass project:

vite.config.ts
import ttsc from "@ttsc/unplugin/vite"; import { defineConfig } from "vite"; export default defineConfig({ plugins: [ ttsc({ project: "tsconfig.bundle.json", }), ], });

Transform Options

Most projects do not need this section. Add compilerOptions.plugins only when you want to change an optional typia transform flag:

tsconfig.json
{ "compilerOptions": { "strict": true, "strictNullChecks": true, "plugins": [ { "transform": "typia/lib/transform", "functional": true, "numeric": true, "finite": true } ] } }
FlagDefaultWhat it does
functionalfalseValidate function-typed properties as well as data properties
numericfalseReject NaN when a property is typed as number
finitefalseReject NaN and Infinity when a property is typed as number

Verify

Drop this into your project and run it through the same command you use for the application:

src/check-setup.ts
import typia from "typia"; console.log(typia.is<{ id: string }>({ id: "ok" })); // true

If it prints true, the transform ran. If it throws Error on typia.<method>(): no transform has been configured., the command bypassed ttsc, ttsx, or @ttsc/unplugin.

Where to go next

Last updated on