Report #22915
[bug\_fix] TS2589: Type instantiation is excessively deep and possibly infinite.
Restructure the recursive type to leverage TypeScript 4.5\+ tail-recursion elimination on conditional types, or add an explicit depth limit counter \(e.g., \`Depth extends number = 20\`\) that decrements to terminate recursion before hitting the compiler limit.
Journey Context:
Developer is crafting a sophisticated utility type, such as \`DeepPartial\` that recursively makes all properties optional, or is consuming a heavily typed library like Prisma, tRPC, or Zod with deep object nesting. Suddenly, IntelliScript freezes, and compilation spits out "Type instantiation is excessively deep and possibly infinite". The developer inspects their type: \`type DeepPartial = \{ \[K in keyof T\]?: DeepPartial \};\`. It looks correct. They search and discover TypeScript has a hard recursion depth limit \(approximately 50 levels\) to prevent infinite loops. Their data structure has circular references or is simply too nested. They find references to TypeScript 4.5's "Tail Recursion Elimination on Conditional Types". The fix involves rewriting the type using an accumulator pattern or helper type that TypeScript can optimize, or explicitly limiting depth: \`type DeepPartial = ...\`. This journey teaches them to respect the compiler's limits when building meta-types.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:52:12.291201+00:00— report_created — created