The compiler and runtime
Type-check without emitting files
Use the compiler as a checker when another tool already transforms and bundles the source.
In most modern projects, tsc never produces the JavaScript you ship. Vite, esbuild, or another build tool strips the types and bundles the output, because doing that without type checking is dramatically faster. That leaves tsc with one job: checking.
Run the project checker without writing output:
npx tsc --noEmit
The compiler checks the complete project but does not write JavaScript, source maps, or declarations. Silence means success. Errors come out in the usual file, line, and message format, and the exit code is non-zero, which is what scripts and CI care about.
Why the bundler is not enough
The two tools answer different questions. A bundler asks whether it can transform and package the source. TypeScript asks whether the program satisfies its type contracts.
A fast transpiler can produce JavaScript even when the types are wrong. This code bundles without complaint:
const port: number = 'three thousand'
It is valid JavaScript once the annotation is stripped. Only the type checker reports the problem:
Type 'string' is not assignable to type 'number'.
So a green build proves very little about your types. Teams learn this the hard way when a refactor breaks twenty call sites and the deploy succeeds anyway.
Make checking a named command
Keep a separate type-check command:
{
"scripts": {
"typecheck": "tsc --noEmit"
}
}
Run it locally and in continuous integration. A successful bundle does not replace it. In CI, run npm run typecheck as its own step next to tests, so a type failure is reported as exactly that instead of hiding inside a build log.
You can also set "noEmit": true in tsconfig.json compilerOptions instead of passing the flag, which keeps the script shorter and makes the project’s intent explicit: this configuration exists for checking, another tool owns the output.
One habit worth building: run the typecheck before you commit, not just before you deploy. The errors are cheapest when the code is still fresh in your head.
Exercise: introduce a type error that still uses valid JavaScript syntax. Confirm that your build tool can transform it while npm run typecheck rejects it.
Lesson completed