TypeScript 5.5 --isolatedDeclarations

TypeScript 5.5 --isolatedDeclarations

How to reduce your monorepo builds from 30 seconds to milliseconds

TypeScript 5.5 introduced --isolatedDeclarations, a game-changing option for monorepos. If you're dealing with nested dependencies and slow builds, this article is for you.

TL;DR - Measurable Impact

  • ✅ Builds: 30+ seconds → milliseconds
  • ✅ Average gain: x3, up to x15
  • ✅ Native .d.ts parallelization
  • ✅ Compatible with Bun, swc, esbuild
  • ⚠️ Trade-off: explicit annotations on public exports

🚨 The Sequential Build Problem

In a monorepo with nested dependencies like A → B → C → D, TypeScript must type-check everything in order to generate .d.ts files.

Typical monorepo architecture:

monorepo/
├── packages/
│   ├── core/          (package A)
│   ├── utils/         (package B, depends on A)
│   ├── components/    (package C, depends on B)
│   └── app/           (package D, depends on C)
└── tsconfig.json

Result? Sequential builds that take:

  • 30 seconds for an average library
  • Several minutes for a complete monorepo
  • Impossible to parallelize because each package waits for the previous .d.ts

✨ The Solution: --isolatedDeclarations

The principle is simple but powerful: each file can be processed independently, in parallel. No need to analyze the entire codebase to generate declarations.

❌ Without --isolatedDeclarations

Build A (10s)
Wait A → Build B (10s)
Wait B → Build C (10s)
Wait C → Build D (10s)
Total: 40 seconds (sequential)

✅ With --isolatedDeclarations

Build A (100ms)
Build B (100ms) // Parallel
Build C (100ms) // Parallel
Build D (100ms) // Parallel
Total: ~100ms (parallel)

📊 Real Benchmarks

Measured Gains

x3
Average gain observed
x15
Maximum gain achieved
<100ms
Time per package

🔧 Practical Migration

tsconfig.json Configuration

{
  "compilerOptions": {
    // Enable the option (TS 5.5+)
    "isolatedDeclarations": true,
    
    // Required to generate .d.ts
    "declaration": true,
    
    // Optional: for monorepos with project references
    "composite": true,
    
    // Recommended
    "strict": true
  }
}

Migration Steps

1

Enable the option

Add "isolatedDeclarations": true in tsconfig.json

2

Run the build

npm run build

TypeScript will flag all exports that need annotations.

3

Use Quick Fixes

VS Code offers automatic Quick Fixes to add missing types. Migration in 5 minutes for most projects.

🎯 Conclusion

TypeScript 5.5 --isolatedDeclarations: Game Changer

  • Builds x3 to x15 faster - immediate workflow gains
  • 🚀Native parallelization - unlocks complex monorepos
  • 💎Clearer API - better documentation and DX
  • 🔧Quick migration - automatic Quick Fixes in 5 minutes

Adopting --isolatedDeclarations isn't just a technical optimization, it's an investment in your team's productivity. Time savings on each build add up quickly: several hours saved per week for a team of 5 developers.

Already using --isolatedDeclarations in production?

Share your experience and benchmarks with the community. Need help optimizing your TypeScript monorepo?

Let's discuss your project

Tags

TypeScriptTypeScript 5.5PerformanceMonorepoBuild ToolsDeveloper ExperienceisolatedDeclarations
🌱Eco-designed site