Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flag to customize type instantiation depth limit #46180

Closed
5 tasks done
DetachHead opened this issue Oct 3, 2021 · 1 comment
Closed
5 tasks done

flag to customize type instantiation depth limit #46180

DetachHead opened this issue Oct 3, 2021 · 1 comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@DetachHead
Copy link
Contributor

DetachHead commented 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.

@sandersn
Copy link
Member

sandersn commented Oct 7, 2021

This is not something we want to do. See the commentary at #45025, right at the end.

@sandersn sandersn closed this as completed Oct 7, 2021
@andrewbranch andrewbranch added Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript labels Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants