CLI & Scripts
ttsc compiles, ttsx runs. This page wires them into package.json scripts and CI; the full flag reference is in Compiler (ttsc) and Execute (ttsx).
package.json scripts
// package.json
{
"scripts": {
"build": "ttsc",
"dev": "ttsc --watch",
"check": "ttsc --noEmit",
"fix": "ttsc fix",
"format": "ttsc format",
"start": "ttsx src/index.ts"
}
}ttsc reads tsconfig.json from the current directory. A different config is -p tsconfig.build.json, a different output directory is --outDir build.
fix applies every fixable lint violation plus format edits, then re-checks. format applies only the edits that cannot change behavior, so it is safe for a pre-commit hook.
Watch mode
npx ttsc --watchRe-compiles on save. Add --preserveWatchOutput to keep your scrollback.
The watcher follows the compilerβs resolved program inputs. New included folders and referenced config or declaration inputs join the session as the project changes, while compiler output and cache products do not trigger another build. Check-stage plugins can additionally publish exact local files and glob populations; those declared inputs stay live through missing files and empty populations without making unrelated documents rebuild the project.
ttsc check --watch also keeps capable check-stage sidecars and their no-emit Programs resident across normal source saves and declared external-data updates. Config, compiler-root, plugin, Go-contributor, and declared-input topology changes start a fresh session, while unsupported plugins continue through the one-shot path.
CI
- run: npx ttsc --noEmitType errors and lint violations fail the same CI step.
Go-source plugins compile to native binaries once, then live in a cache. Cache the directories that ttsc cache paths --json prints, and warm them with ttsc prepare, so CI stops rebuilding them every run.
One-off scripts with ttsx
Use ttsx for scripts such as seeders and migrations. It type-checks the project before executing the script.
Arguments after -- go to the script untouched, and -r preloads modules Node-style:
npx ttsx src/server.ts -- --port 3000
npx ttsx -r dotenv/config src/index.tsWorkspace dependencies that ship raw TypeScript load fine; the module hooks behind that are in Execute (ttsx).