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.
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.
typia’s native transform requires ttsc 0.19.2 or newer. On an older ttsc the transform fails to build.
Install
npm
npm i typia
npm i -D ttsc typescriptKeep the TypeScript project strict:
{
"compilerOptions": {
"strict": true
}
}Build
Use ttsc where you would normally run a TypeScript compiler:
npm
npx ttsc
npx ttsc --noEmit
npx ttsc --watchExecute Without Building
Use ttsx instead of runners that strip TypeScript before typia can transform it:
npm
npx ttsx src/index.tsThe 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.
npm i -D @ttsc/unpluginimport 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:
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:
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"plugins": [
{
"transform": "typia/lib/transform",
"functional": true,
"numeric": true,
"finite": true
}
]
}
}| Flag | Default | What it does |
|---|---|---|
functional | false | Validate function-typed properties as well as data properties |
numeric | false | Reject NaN when a property is typed as number |
finite | false | Reject 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:
import typia from "typia";
console.log(typia.is<{ id: string }>({ id: "ok" }));
// trueIf 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
- First validator after setup:
is,assert,validate - Why typia needs a transform: Pure TypeScript
- Bundled framework recipes: Utilization Cases