Skip to Content

TypeScript-Go (ttsc)

This setup targets TypeScript-Go — the Go rewrite of the TypeScript compiler that ships under @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 project
  • ttsx — execute a TypeScript file directly, with type checking
  • @ttsc/unplugin — connect ttsc to a bundler (Vite, Next.js, Webpack, …)
Note

@typescript/native-preview is not yet a stable TypeScript release, and typia@next is the matching experimental release of typia. For production today, 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

Terminal
npm i typia@next npm i -D ttsc @typescript/native-preview

Then keep your TypeScript project strict:

tsconfig.json
{ "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:

Terminal
npx ttsc # build npx ttsc --noEmit # type-check only npx ttsc --watch # rebuild on change

Execute without building

Use ttsx instead of ts-node or tsx:

Terminal
npx ttsx src/index.ts

Bundlers

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

Terminal
npm i -D @ttsc/unplugin

Configure

@ttsc/unplugin exposes one entry per bundler — import the matching path:

vite.config.ts
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.config.ts
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:

tsconfig.json
{ "compilerOptions": { "strict": true, "strictNullChecks": true, "plugins": [ { "transform": "typia/lib/transform", "functional": true, // default: false "numeric": true, // default: false "finite": true // default: false } ] } }
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
Note

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

Last updated on