Skip to Content

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 project
  • ttsx โ€” execute a TypeScript file directly, with type checking
  • @ttsc/unplugin โ€” connect ttsc to a bundler (Vite, Next.js, Webpack, โ€ฆ)
Note

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

Terminal
npm i typia@next npm i -D ttsc typescript@rc

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