Skip to content

Commit 0759bc6

Browse files
committed
Fix inference to indexed access type containing substitution type
1 parent 454b428 commit 0759bc6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14860,6 +14860,14 @@ namespace ts {
1486014860
target = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, matchingTypes);
1486114861
}
1486214862
}
14863+
else if (target.flags & TypeFlags.Substitution) {
14864+
target = (target as SubstitutionType).typeVariable;
14865+
}
14866+
else if (target.flags & TypeFlags.IndexedAccess && (
14867+
(<IndexedAccessType>target).objectType.flags & TypeFlags.Substitution ||
14868+
(<IndexedAccessType>target).indexType.flags & TypeFlags.Substitution)) {
14869+
target = getIndexedAccessType(getActualTypeVariable((<IndexedAccessType>target).objectType), getActualTypeVariable((<IndexedAccessType>target).indexType));
14870+
}
1486314871
if (target.flags & TypeFlags.TypeVariable) {
1486414872
// If target is a type parameter, make an inference, unless the source type contains
1486514873
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
@@ -14921,9 +14929,6 @@ namespace ts {
1492114929
}
1492214930
}
1492314931
}
14924-
else if (target.flags & TypeFlags.Substitution) {
14925-
inferFromTypes(source, (target as SubstitutionType).typeVariable);
14926-
}
1492714932
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
1492814933
// If source and target are references to the same generic type, infer from type arguments
1492914934
const sourceTypes = (<TypeReference>source).typeArguments || emptyArray;

0 commit comments

Comments
 (0)