Skip to content

flag to customize type instantiation depth limitΒ #46180

Closed

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions