Skip to content

Properly reduce intersections of string literal and template literal types #41162

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

Merged
merged 3 commits into from
Oct 19, 2020

Conversation

ahejlsberg
Copy link
Member

Fixes #41161.

@ahejlsberg ahejlsberg requested a review from weswigham October 19, 2020 15:47
@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Oct 19, 2020
@ahejlsberg ahejlsberg added this to the TypeScript 4.1.1 milestone Oct 19, 2020
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is fine, but the reduce operation has the potential to be very expensive on large input sets. Are we sure there's not a way re can rejigger how we read the cache to keep the operation cached (even when the final result is never)?

@ahejlsberg
Copy link
Member Author

@weswigham I think it's going to be quite rare to have large intersection input sets that contain both string literal types and template literal types so I'm not too worried about it. I think the common pattern here will be intersecting a large union of string literal types with a template literal type, but that'll normalize to a large union of little intersections.

@ahejlsberg ahejlsberg merged commit 4638c68 into master Oct 19, 2020
@ahejlsberg ahejlsberg deleted the fix41161 branch October 19, 2020 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intersections with template literal types not correctly reduced
3 participants