Course contentsShow
← TypeScript
Lesson 1751 of 1,79639. TypeScript PerformanceFree lesson

excludeFiles and IDE Performance

Using tsconfig exclude patterns to prevent the compiler from processing unnecessary files in the editor.

excludeFiles and IDE Performance

You'll learn: How to use tsconfig.json exclude patterns to dramatically improve your editor's responsiveness by preventing TypeScript from processing unnecessary files.


The IDE Performance Problem

When you open a TypeScript project, your IDE's language service scans and type-checks every TypeScript file it finds. This includes files in node_modules, build output folders, test fixtures, and generated code directories. Processing thousands of unnecessary files can make autocomplete sluggish, hover information slow, and background type-checking consume CPU cycles continuously.

Think of it like a librarian who insists on cataloging every single piece of paper in the building—including receipts, scratch notes, and duplicates—before they can help you find a book. You need them to focus only on the actual library collection.


Using exclude to Ignore Files

The exclude property in tsconfig.json tells TypeScript's compiler—and your IDE's language service—to completely ignore certain files and directories:

{
  "compilerOptions": {
    "strict": true,
    "outDir": "./dist"
  },
  "exclude": [
    "node_modules",
    "dist",
    "build",
    "coverage",
    "**/*.test.ts",
    "scripts"
  ]
}

This configuration tells TypeScript: "Don't process anything in node_modules, the output directories, test files, or the scripts folder." Your IDE respects this and stops analyzing those files entirely.


Common Directories to Exclude

Output directories: dist, build, out—these contain compiled JavaScript, not source code you're editing.

Test artifacts: coverage, __snapshots__—type-checking coverage reports is pointless.

Dependencies: node_modules (usually excluded by default, but explicit is better).

Generated code: If you have code generation steps, exclude the output folders.

Scripts and tooling: Build scripts or utilities that aren't part of your application.


The Performance Impact

Excluding unnecessary directories can reduce your project's type-checking scope from 50,000 files to 500 files. The IDE language service becomes orders of magnitude faster:

  • Autocomplete appears instantly instead of after a delay
  • Hover tooltips show immediately
  • Background error checking completes in seconds, not minutes
  • Memory usage drops significantly

You've removed the noise and let your IDE focus on the code you actually work with.


Exclude vs Include

The exclude pattern works alongside include. If you specify include, TypeScript only looks at those files—then applies exclude to filter out exceptions:

{
  "include": ["src/**/*"],
  "exclude": ["src/**/*.test.ts"]
}

This says: "Process everything in src, except test files."


Key Takeaway: Using exclude in your tsconfig.json is one of the simplest and most effective ways to speed up your IDE by preventing TypeScript from analyzing build artifacts, dependencies, and other non-source files—turning a slow editor into a responsive one.