Skip to content

Conversation

@ahejlsberg
Copy link
Member

Fixes #31086.

else if (target.flags & TypeFlags.IndexedAccess && (
(<IndexedAccessType>target).objectType.flags & TypeFlags.Substitution ||
(<IndexedAccessType>target).indexType.flags & TypeFlags.Substitution)) {
target = getIndexedAccessType(getActualTypeVariable((<IndexedAccessType>target).objectType), getActualTypeVariable((<IndexedAccessType>target).indexType));
Copy link
Member

Choose a reason for hiding this comment

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

What about a Substitute<T[Substitute<K>]>? Substitutes can in theory nest arbitrarily, provided they keep instantiating to type variables.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved the logic to getActualTypeVariable and made it recurse appropriately.

@ahejlsberg ahejlsberg merged commit 9509a54 into master May 1, 2019
@ahejlsberg ahejlsberg deleted the fixInferenceToIndexedAccessWithSubstitution branch May 1, 2019 00:45
@timsuchanek
Copy link
Contributor

Just tried it out - I can confirm that it's now working 🎉
Thanks for fixing this so quick!

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in 3.4: Type inference with generic type guard breaks

5 participants