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

Fix incorrect rest element type inside contextually typed parameter #47909

Merged
merged 4 commits into from Feb 15, 2022

Conversation

gabritto
Copy link
Member

Fixes #47865.

When pushing down the instantiated contextual type from a parameter to its binding elements (i.e. a parameter that is a binding pattern), we relied on storing this parameter type in our type cache (symbolLinks.type), and retrieving this cached type when computing the type of its binding elements (in assignBindingElementTypes). However, if the binding element is a rest binding element, as of #47337 we skip looking for its parent type in the cache, because checkMode is going to have CheckMode.RestBindingElement set, and we compute the wrong (uninstantiated) type for the parent.
This fix makes it so we explicitly pass the parent type in assignBindingElementTypes, avoiding the need to rely on getting the cached type.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 15, 2022
@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-4.6

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2022

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-4.6 on this PR at b618cf9. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I've opened #47912 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Feb 15, 2022
Component commits:
f4a5562 wip: possible fixes

75cb739 pass parameter type to assignBindingElementTypes

4a7de63 undo unnecessary changes

b618cf9 update baselines
@gabritto gabritto merged commit 67f47bf into main Feb 15, 2022
@gabritto gabritto deleted the gabritto/issue47865 branch February 15, 2022 21:27
RyanCavanaugh pushed a commit that referenced this pull request Feb 16, 2022
Component commits:
f4a5562 wip: possible fixes

75cb739 pass parameter type to assignBindingElementTypes

4a7de63 undo unnecessary changes

b618cf9 update baselines

Co-authored-by: Gabriela Araujo Britto <gabrielaa@microsoft.com>
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
None yet
Development

Successfully merging this pull request may close these issues.

Unable to read properties off object spread in generic function parameter (regression with 4.6.1-rc)
4 participants