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

Use skipLibCheck to Skip node_modules

Enable skipLibCheck in tsconfig to avoid type-checking third-party declaration files unnecessarily.

Use skipLibCheck to Skip node_modules

You'll learn: How enabling skipLibCheck dramatically speeds up TypeScript compilation by skipping type-checking in third-party declaration files.

What skipLibCheck Does

TypeScript by default type-checks all .d.ts files in your project, including thousands of declaration files buried in node_modules. This means checking React's types, Express's types, and every other library—even though you didn't write them and they're already published.

skipLibCheck: true tells TypeScript: "Trust that third-party declaration files are correct. Don't waste time checking them."

Think of it like a security checkpoint: normally, TypeScript inspects everyone's bags—even trusted airline staff. With skipLibCheck, you only check your bags, trusting that the professionals have already been vetted.

When This Matters

In large projects with many dependencies, type-checking node_modules can consume 30-70% of your build time. The types in popular packages like @types/node or @types/react are massive and rarely contain errors that affect your code.

Enabling skipLibCheck is one of the single most effective compiler optimizations. It's enabled by default when you use the strict flag preset.

The Trade-off

You sacrifice catching rare conflicts between declaration files. For example, if two libraries define incompatible global types, you won't see errors until runtime. In practice, this is extremely rare and worth the speed gain.

Configuration

Add this to your tsconfig.json:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}

Key Takeaway: Enable skipLibCheck: true to dramatically speed up compilation by skipping type-checking in node_modules—the benefits almost always outweigh the negligible risk of missing third-party type conflicts.