TypeScript Reference ยท The tsc Command Line
tsc --noEmit
Reference for tsc --noEmit: running only the type checker, using it in CI and with bundlers, and how it interacts with incremental builds and exit codes.
tsc --noEmit runs the whole type checker and writes nothing: no .js, no .d.ts, no source maps. The only result is the list of errors and the exit status.
That is exactly what you want when something else produces the JavaScript. Bundlers such as Vite or esbuild, Babel, Node's own type stripping, and test runners all remove types without checking them, so tsc --noEmit is the step that actually enforces the types.
tsc --noEmit tsc -p tsconfig.json --noEmit
Try it
Because tools that strip types never complain about type errors, this program would run fine if types were simply erased. The checker is what catches it.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
tsc --noEmit
{ "compilerOptions": { "noEmit": true } }
Behavior: the program is fully parsed and checked, then emit is skipped. With errors, the exit code is 1; with none it is 0.
Edge cases: noEmit together with composite or declaration conflicts in older setups, because those need output. Use emitDeclarationOnly for a declarations-only build instead. With incremental, tsc --noEmit may still write a .tsbuildinfo file (in recent versions it does so to speed up later checks).
Usage notes
- CI recipe: an npm script
"typecheck": "tsc --noEmit"run next to lint and tests. - Pair it with
isolatedModulesandverbatimModuleSyntax, so what the checker accepts is also safe for single-file transpilers. - Faster in watch mode:
tsc --noEmit --watchkeeps the checker warm during development. - Does not replace tests. It proves types fit, not that values are right.
- Decide on
noEmitOnErrorif you do emit: it stops JavaScript from being written when there are errors. It is the opposite trade-off from--noEmit.
Related
- noEmit
- noEmitOnError
- tsc exit codes
- Tutorial: Tooling