Skip to content

Fix contextual typing for symbol-named properties #46558

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

Merged
merged 3 commits into from
Nov 2, 2021
Merged

Fix contextual typing for symbol-named properties #46558

merged 3 commits into from
Nov 2, 2021

Conversation

ahejlsberg
Copy link
Member

This PR fixes contextual typing for symbol-named properties and also updates the index signature in PropertyDescriptorMap to use PropertyKey as the index type (thus declaring index signatures for each of string | number | symbol).

Fixes #43628.

@ahejlsberg ahejlsberg requested a review from sandersn October 27, 2021 23:45
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Oct 27, 2021
@ahejlsberg
Copy link
Member Author

@andrewbranch @sandersn The update to PropertyDescriptorMap seems to have no ill effects (in fact, nothing changes in any of our tests).

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I vote to hold this for 4.6.

@ahejlsberg ahejlsberg merged commit 33fe1b6 into main Nov 2, 2021
@ahejlsberg ahejlsberg deleted the fix43628 branch November 2, 2021 21:05
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
* Properly handle symbol-named properties in contextual types

* Update index signature in PropertyDescriptorMap

* Add regression tests
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.

Type of symbol-named computed property is contextually typed with string literal
3 participants