Report #11999
[bug\_fix] Type instantiation is excessively deep and possibly infinite.ts\(2589\)
Refactor recursive type definitions to use tail-recursion elimination or add depth limiting using a counter type \(e.g., Prev\[Depth\] extends never ? never : Recursive\). Alternatively, enable 'skipLibCheck': true to bypass type checking in node\_modules if the error originates from a library \(like Prisma, tRPC, or Zod with complex schemas\). The root cause is TypeScript's recursion depth limit \(typically ~50 levels\) being exceeded by deeply nested generic instantiations.
Journey Context:
You're building a complex type-safe router using tRPC or defining a deep Zod schema for a large form. Suddenly, VS Code freezes, then shows red squiggles: 'Type instantiation is excessively deep and possibly infinite'. Your generic type Utilities.DeepMerge or Paths is causing it. You check the type definition—it's recursive, drilling down into nested objects. You remember TypeScript has a recursion limit. You try to simplify the type, but it's from a library. You search GitHub and find issue \#30118. You see suggestions: upgrade TypeScript \(newer versions have better tail-call optimization\), add depth counters to your own types, or use skipLibCheck to ignore the complex types in node\_modules if you don't need them checked. You add skipLibCheck: true to tsconfig, reload, and the error disappears. You understand that TypeScript was spending too long checking infinitely recursive type definitions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:49:17.467991+00:00— report_created — created