Skip to content

Commit

Permalink
Fix inference to indexed access type containing substitution type
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Apr 27, 2019
1 parent 454b428 commit 0759bc6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/compiler/checker.ts
Expand Up @@ -14860,6 +14860,14 @@ namespace ts {
target = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, matchingTypes);
}
}
else if (target.flags & TypeFlags.Substitution) {
target = (target as SubstitutionType).typeVariable;
}
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));
}
if (target.flags & TypeFlags.TypeVariable) {
// If target is a type parameter, make an inference, unless the source type contains
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
Expand Down Expand Up @@ -14921,9 +14929,6 @@ namespace ts {
}
}
}
else if (target.flags & TypeFlags.Substitution) {
inferFromTypes(source, (target as SubstitutionType).typeVariable);
}
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
// If source and target are references to the same generic type, infer from type arguments
const sourceTypes = (<TypeReference>source).typeArguments || emptyArray;
Expand Down

0 comments on commit 0759bc6

Please sign in to comment.