TypeScript-Go (ttsc)
This setup targets TypeScript-Go โ the Go rewrite of the TypeScript compiler, now shipping as the typescript@7 release candidate (formerly @typescript/native-preview). typia@next ships a Go-rewritten transform that plugs into it through the ttsc toolchain.
You need three commands:
ttscโ build, check, and watch a TypeScript projectttsxโ execute a TypeScript file directly, with type checking@ttsc/unpluginโ connectttscto a bundler (Vite, Next.js, Webpack, โฆ)
typescript@7 is a release candidate, and typia@next is the matching prerelease of typia. For a fully stable toolchain, use the Legacy (TS v6) setup.
The stock tsc, ts-node, and tsx cannot apply the typia transform โ you must use ttsc and ttsx.
Install
npm
npm i typia@next
npm i -D ttsc typescript@rcThen keep your TypeScript project strict:
{
"compilerOptions": {
"strict": true
}
}Thatโs it. Unlike the legacy setup, you do not add compilerOptions.plugins for typia โ ttsc discovers the transform from the ttsc field in typia/package.json automatically.
Build
Use ttsc exactly the way you would use tsc:
npm
npx ttsc # build
npx ttsc --noEmit # type-check only
npx ttsc --watch # rebuild on changeExecute without building
Use ttsx instead of ts-node or tsx:
npm
npx ttsx src/index.tsBundlers
Bundlers (Vite, Next.js, Webpack, โฆ) run their own TypeScript pipeline that bypasses ttsc. To plug typia in, install @ttsc/unplugin and add its plugin to your bundler config.
Install
npm
npm i -D @ttsc/unpluginConfigure
@ttsc/unplugin exposes one entry per bundler โ import the matching path:
Vite
import ttsc from "@ttsc/unplugin/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [ttsc()],
});Drop the plugin into the same config file that already builds your app (vite.config.ts, next.config.mjs, webpack.config.mjs, โฆ). After that, run your normal build command โ no other change.
Pointing at a different tsconfig.json
If your bundler should use a config other than the default tsconfig.json, pass project:
Vite
import ttsc from "@ttsc/unplugin/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
ttsc({
project: "tsconfig.bundle.json",
}),
],
});The project path is resolved from the current working directory.
Tuning the transform
Most projects donโt need to touch this. Add compilerOptions.plugins only when you want to flip one of the optional transform flags:
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"plugins": [
{
"transform": "typia/lib/transform",
"functional": true, // default: false
"numeric": true, // default: false
"finite": true // default: false
}
]
}
}| 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 |
With the default flags you do not need compilerOptions.plugins. ttsc will pick up the transform from typia/package.json on its own.
Where to go next
- Stable production alternative โ Legacy setup
- First validator after setup โ
isยทassertยทvalidate - Why typia needs a transform at all โ Pure TypeScript