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

Fixed an issue with reverse mapped types inference when single type variable is left after inferring from matching types #55941

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Oct 2, 2023

No description provided.

…ariable is left after inferring from matching types
@@ -25078,7 +25078,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
target = getIntersectionType(targets);
}
}
else if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) {
if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

preceding logic (such as the one responsible for inferring from matching types in unions here) could "reduce" the target in various ways - potentially to leaving indexed access or substitution in the target (when the target doesn't start as such). For that reason, we always need to getActualTypeVariable here as it should be called on the "reduced" target and not based on the pre-reduction flags (which sort of happened when this condition was used as just a fallback branch)

@sandersn sandersn added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 1, 2023
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.

Obligatory "Does this have a matching issue?", but this looks good to me. Honestly surprising if we haven't gotten any issue reports about inference failure that boil down to this, since it doesn't seem that hard to trigger.

@sandersn sandersn merged commit 6edfef8 into microsoft:main Nov 30, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants