Skip to content

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

Merged
sandersn merged 2 commits intomicrosoft:mainfrom
Andarist:fix/reverse-mapped-types-inference-after-matching-types
Nov 30, 2023
Merged

Fixed an issue with reverse mapped types inference when single type variable is left after inferring from matching types#55941
sandersn merged 2 commits intomicrosoft:mainfrom
Andarist:fix/reverse-mapped-types-inference-after-matching-types

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Oct 2, 2023

No description provided.

…ariable is left after inferring from matching types
Comment thread src/compiler/checker.ts
}
}
else if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) {
if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) {
Copy link
Copy Markdown
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
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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