Description
openedon Oct 3, 2021
Suggestion
π Search Terms
customize type instantiation depth limit
β Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
it seems that the type instantiation depth limit changes quite often (most recently in #45711). i think it would be useful to be able to customize this behavior in compiler flags such as typeInstantiationDepthLimit
and tailRecursionTypeInstantiationDepthLimit
though i'm not sure how this would work if a project depends on a project that customizes these...
π» Use Cases
i have a repository of utility types, many of which use recursive conditional types and rely on the depth limit being quite high. a workaround for the depth limit i've been using is this logarithmic approach, but with the new tail recursion change i've been thinking of replacing it with a much simpler implementation, though that would change the limit from 10000 to 1000.