Using tsc --noEmit for CI
You'll learn how to run TypeScript's type-checker in your continuous integration pipeline without generating any output files.
What Is --noEmit?
The --noEmit flag tells the TypeScript compiler to perform all type-checking but skip the file generation step entirely. Think of it like a proofreader who marks up your manuscript but doesn't print a new copy—you get all the feedback without the overhead of producing output.
This is perfect for CI environments where you only care about catching type errors, not building artifacts. Your actual build step might use a bundler like Webpack or esbuild for speed, but you still want TypeScript's full type safety verification.
Why Use This in CI?
In continuous integration, you typically want to validate that:
- No type errors exist in your codebase
- All imports resolve correctly
- Your types are internally consistent
You don't need the compiled .js files because:
- Your bundler will handle transpilation separately
- CI doesn't deploy the code—it just validates it
- Generating files wastes time and disk space
Running tsc --noEmit
From the command line:
tsc --noEmit
Or in your package.json scripts:
{
"scripts": {
"typecheck": "tsc --noEmit"
}
}
Then in your CI configuration (GitHub Actions, GitLab CI, etc.), you run npm run typecheck as a validation step. If types don't match, the command exits with a non-zero code and fails the build—exactly what you want.
The Separation of Concerns
This approach embraces the modern pattern: use TypeScript for type-checking (tsc --noEmit) and fast bundlers for transpilation (esbuild, swc). You get safety without sacrificing build speed.
Key Takeaway: tsc --noEmit performs full type-checking without generating files, making it ideal for CI validation pipelines where you want safety guarantees without build artifacts.