Course contentsShow
← TypeScript
Lesson 77 of 1,7962. Setup and ToolingFree lesson

The --noEmit Flag: Type-Checking Without Output

Discover when and why to type-check without generating JavaScript files, useful for build tools and CI.

The --noEmit Flag: Type-Checking Without Output

What you'll learn: How to use TypeScript purely as a validator without generating any JavaScript files.

What Is --noEmit?

The --noEmit flag tells TypeScript's compiler to check your code for type errors but skip producing any .js output files. Think of it like a spell-checker that highlights mistakes in your essay but doesn't print a corrected version—you're just verifying correctness.

When and Why Use It

You'll commonly use --noEmit in two scenarios:

1. Build Tools Already Handle Compilation
When using bundlers like Webpack, Vite, or Parcel (as you learned previously), they transform your TypeScript to JavaScript. You don't need tsc to emit files—you only need it to verify types. Running tsc --noEmit ensures type safety without duplicating compilation work.

2. Continuous Integration (CI) Checks
In automated testing pipelines, you want to catch type errors before merging code. Since CI doesn't need the actual JavaScript output (just pass/fail validation), --noEmit runs faster and keeps your build logs cleaner.

How to Use It

Run from the command line:

tsc --noEmit

Or add it to your tsconfig.json:

{
  "compilerOptions": {
    "noEmit": true
  }
}

This is perfect alongside tsc --watch for real-time type checking while your bundler handles builds separately.

Analogy

Imagine a factory inspector (TypeScript) checking products for defects. Normally, the inspector also packages approved items. With --noEmit, the inspector only reports defects—a separate packaging line handles the actual shipping.

Key Takeaway: Use --noEmit when you need type safety validation but another tool is already creating your JavaScript output—common in modern build pipelines and CI environments.