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

Running Type Checks Without Emitting Files

Use tsc --noEmit to verify types without producing JavaScript output, useful in CI or pre-commit hooks.

Running Type Checks Without Emitting Files

What you'll learn: How to verify your TypeScript code's type correctness without generating JavaScript files, perfect for validation workflows.

The Core Idea

Sometimes you don't want to actually compile your TypeScript to JavaScript—you just want to know if there are any type errors. Think of it like a spell-checker that reads your document but doesn't save a new copy. The tsc --noEmit flag does exactly this: it runs the full type-checking process but skips the file generation step.

Why This Matters

When you run tsc normally, TypeScript checks your types and outputs JavaScript files to your outDir. But in several scenarios, you only care about the type-checking:

  • CI/CD pipelines: Your build tool (like Vite or Webpack) already handles compilation, so you just want TypeScript to validate types before deployment
  • Pre-commit hooks: Catch type errors before code reaches your repository
  • Monorepos: Check types across packages without generating duplicate outputs

The Command

tsc --noEmit

This runs through your entire project (based on tsconfig.json), reports any type errors in your terminal, and then stops—no .js files created.

Real-World Example

Imagine your build process already uses Vite, which compiles TypeScript internally. You don't need tsc to create JavaScript files, but you do want TypeScript's strict type checking in your continuous integration. Add tsc --noEmit to your CI script, and it'll fail the build if types don't align—without interfering with Vite's output.

Key Takeaway: Use tsc --noEmit when you want TypeScript's type safety guarantees without generating JavaScript files, keeping your type checks separate from your build process.