Skip to content

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).

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 27, 2021
@weswigham weswigham closed this Jun 17, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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