Report #88143
[bug\_fix] Type instantiation is excessively deep and possibly infinite.
Refactor recursive utility types to use tail-recursion elimination \(TypeScript 4.5\+\) by adding a depth counter that defaults to a limit \(e.g., Depth extends number = 10\), or use the Simplify utility from type-fest to flatten intersections.
Journey Context:
Developer is using a utility type like DeepPartial or a complex type from a library like Prisma or tRPC that recursively maps over object properties. They attempt to use this type on a large interface or a circular structure. The TypeScript compiler hangs for several seconds then throws TS2589, or the IDE becomes unresponsive. Developer investigates the utility type and sees it calls itself recursively: type DeepPartial = \{ \[P in keyof T\]?: DeepPartial; \}. The depth of recursion exceeds TypeScript's internal limit \(usually ~50\). Prior to TS 4.5, this was a hard limit. The fix involves two strategies: \(1\) If on TS 4.5\+, refactor the conditional type to use tail-recursion elimination by adding a depth counter type parameter that decrements until a base case is reached, preventing infinite recursion. \(2\) Simplify the type using Simplify from type-fest to collapse complex intersections that might be triggering the deep instantiation during assignment, breaking the recursive chain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:32:07.807326+00:00— report_created — created