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

Negative cases of getNarrowedType that match the exact type should be filtered out, even when generic #45205

Closed
wants to merge 1 commit into from

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Jul 27, 2021

Fixes #44404

The reported regression is caused by the changes in #43763 - in breaking apart constraints in negative cases, we made it so First (a generic) could never remove First (itself), since First is constrained to {foo: string} (yet obviously isn't related to the generic subtype in question). With this change to that, we do not perform the constraint check if the candidate exactly matches - this is easily foiled (by subtypes and intersections).

See, the thing is - after some investigation, I've decided this is a kind of hacky fix layered on a hacky fix.
#43763 is ultimately doing the best it can to work around the fact that the subtype comparison result for Slice[A][B] and Extract<Slice[A][B]. whatever> is wrong - a root cause bug which #41821 fixes. I think, rather than this, we should be looking to pull in #41821 and completely revert the non-test changes in #43763 (since I can confirm the issue is also fixed by #41821). That combined change can be found here, if we think we'd like to do that, instead (the relevant diff has been merged into #41821).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Union types are not being narrowed correctly in generic functions in 4.3
2 participants