Using tsc --noEmit for Type-Checking Only
What you'll learn: How to run TypeScript purely for type validation while letting your bundler handle code transformation.
The Core Idea
The --noEmit flag tells the TypeScript compiler to perform all its type-checking work but skip writing any output files to disk. This is the perfect setup when you're using a bundler like Webpack, Rollup, or esbuild to handle the actual JavaScript transformation, but you still want TypeScript's safety guarantees.
Think of it like having a proofreader who checks your manuscript for errors but doesn't publish the book — that's someone else's job.
Why This Matters
Modern build pipelines typically separate concerns:
- TypeScript: Validates types, catches errors
- Bundler: Transforms code, optimizes bundles, handles imports
Running tsc --noEmit means you get compile-time safety without duplicating the transpilation work or creating unnecessary intermediate files.
How It Works
When you run:
tsc --noEmit
TypeScript will:
- ✅ Read your
tsconfig.jsonconfiguration - ✅ Parse all included TypeScript files
- ✅ Perform full type-checking
- ✅ Report any type errors
- ❌ Skip writing
.js,.d.ts, or.mapfiles
This is dramatically faster than full compilation and keeps your file system clean.
Common Integration Pattern
In a typical project using Vite, esbuild, or similar:
{
"scripts": {
"type-check": "tsc --noEmit",
"build": "vite build"
}
}
Your bundler transforms the code, tsc --noEmit validates the types — clean separation of responsibilities.
Key Takeaway: Use tsc --noEmit to validate types without generating files, letting your bundler handle transformation while TypeScript focuses purely on catching errors.