-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
rewrite recursive conditional types to be tail-recursive #255
Comments
That would be an awesome addition :) Have you evaluated which types aren't working out of the box? |
ones i've noticed so far are listed in the description of #256 - will update the list as i come across more |
there's also i'm not sure how to go about updating it, i don't want to just add 1000 more entries to it because that seems gross. perhaps there's a better solution? |
That is totally fine. The map itself is not dynamic on purpose and is there to optimize TypeScript to make iteration convenient and efficient. In essence, it's there to teach TypeScript how to count. The |
That would be a conclusive experiment to know if types like |
@millsp ok i've updated |
is there a reason for using type Foo<T> = {
0: 'foo'
1: 'bar'
}[Condition<T>] but i don't think that works for tail recursion optimization. is it purely for readability? |
Yes, it's because you can index with |
ah cool i had no idea. so are you ok with me rewriting some of them to use what are your thoughts? |
I also think so. That means that this will be quite an amount of work. In the entry point of the lib, I provided a regex for finding all the recursive types - that will give us an idea of how much there is to do. I'll be happy to contribute on this PR with you :) |
sounds good, i had a look through the codebase and yeah it seems like a lot more work than i initially thought and probably won't have the time to do it all myself so any help is appreciated |
🍩 Feature Request
Is your feature request related to a problem?
many types in ts toolbelt use recursive conditional types, meaning that using them often results in stack depth errors.
Describe the solution you'd like
in typescript 4.5, tail-recursive conditional types are now optimized such that the recursion limit can be much higher (1000) instead of 100. see the blog post and microsoft/TypeScript#45711
Describe alternatives you've considered
Teachability, Documentation, Adoption, Migration Strategy
The text was updated successfully, but these errors were encountered: