Skip to Content

Summary

typia@next uses the ttsc toolchain.

This setup targets TypeScript-Go, the Go migration of the TypeScript compiler. ttsc provides the Go-based plugin toolchain, and typia@next uses the Go-rewritten typia transform.

  • ttsc: build, check, and watch TypeScript projects
  • ttsx: execute TypeScript directly with type checking
  • @ttsc/unplugin: run ttsc plugins from bundlers
Note

@typescript/native-preview is not a stable TypeScript release yet, and typia@next is also an experimental release of typia.

Also, you must use ttsc and ttsx. The stock tsc, ts-node, and tsx cannot apply the typia transform, so they will not work.

Setup

Install

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

Keep your TypeScript project strict.

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

Compile

Use ttsc to build your TypeScript project. It compiles your sources and applies the typia transform in one step.

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

Execute

Use ttsx to run a TypeScript file directly, without a build step.

Terminal
npx ttsx src/index.ts

Bundlers

Install

Use @ttsc/unplugin when your project is built by a bundler.

ttsc is enough for a normal TypeScript build, but bundlers run their own build pipeline. @ttsc/unplugin connects the ttsc transform to that pipeline.

Terminal
npm i -D @ttsc/unplugin

Configuration

Currently, @ttsc/unplugin supports the following bundlers:

  • Vite
  • Next.js
  • Rollup
  • Rolldown
  • esbuild
  • Webpack
  • Rspack
  • Farm
  • Bun

Then add the matching plugin to your bundler config. Import path must match the bundler you are using.

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

Put the plugin in the same config file that already builds your application. For example, a Vite app uses vite.config.ts, a Next.js app uses next.config.mjs, and a Webpack app uses webpack.config.mjs.

After that, run the normal build command of your framework or bundler.

Project

If your bundler should read another TypeScript config file, 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.

Transform Options

Add compilerOptions.plugins only when you want to change transform options.

tsconfig.json
{ "compilerOptions": { "strict": true, "strictNullChecks": true, "plugins": [ { "transform": "typia/lib/transform", "functional": true, // default: false "numeric": true, // default: false "finite": true, // default: false "undefined": false // default: true } ] } }
  • functional: validate function types
  • numeric: reject NaN from number
  • finite: reject both NaN and Infinity from number
  • undefined: set false to skip explicit undefined checks
Note

If you use the default transform options, do not add compilerOptions.plugins to tsconfig.json.

ttsc automatically applies the typia transform. This is the difference from the legacy setup.

Last updated on