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

Allow indexed access with known keys on otherwise deferrable indexed access on generic object #51176

Closed
wants to merge 2 commits into from

Conversation

Andarist
Copy link
Contributor

fixes #51161

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Oct 14, 2022
@@ -36437,6 +36443,9 @@ namespace ts {
return type;
}
if (isGenericObjectType(objectType)) {
if (isTypeAssignableTo(indexType, getImmediateIndexType(apparentObjectType, /*stringsOnly*/ false))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't fully expect this to be the final solution - but I think that some form of this is sound. I'm just unsure if I should avoid doing this in some situations or if there is a better way to compare the available keys on this apparentObjecType/objectType with the indexType.

@Andarist
Copy link
Contributor Author

Andarist commented Mar 5, 2023

got superseded by #53098

@Andarist Andarist closed this Mar 5, 2023
@Andarist Andarist deleted the fix/51161 branch March 5, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Key that must exist on generic type T cannot be used to index type type T
3 participants