@@ -10386,7 +10386,7 @@ namespace ts {
10386
10386
// results for union and intersection types for performance reasons.
10387
10387
function couldContainTypeVariables(type: Type): boolean {
10388
10388
const objectFlags = getObjectFlags(type);
10389
- return !!(type.flags & TypeFlags.TypeVariable ||
10389
+ return !!(type.flags & ( TypeFlags.TypeVariable | TypeFlags.Index) ||
10390
10390
objectFlags & ObjectFlags.Reference && forEach((<TypeReference>type).typeArguments, couldContainTypeVariables) ||
10391
10391
objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) ||
10392
10392
objectFlags & ObjectFlags.Mapped ||
@@ -10554,6 +10554,13 @@ namespace ts {
10554
10554
inferFromTypes(sourceTypes[i], targetTypes[i]);
10555
10555
}
10556
10556
}
10557
+ else if (source.flags & TypeFlags.Index && target.flags & TypeFlags.Index) {
10558
+ inferFromTypes((<IndexType>source).type, (<IndexType>target).type);
10559
+ }
10560
+ else if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) {
10561
+ inferFromTypes((<IndexedAccessType>source).objectType, (<IndexedAccessType>target).objectType);
10562
+ inferFromTypes((<IndexedAccessType>source).indexType, (<IndexedAccessType>target).indexType);
10563
+ }
10557
10564
else if (target.flags & TypeFlags.UnionOrIntersection) {
10558
10565
const targetTypes = (<UnionOrIntersectionType>target).types;
10559
10566
let typeVariableCount = 0;
@@ -10627,6 +10634,12 @@ namespace ts {
10627
10634
}
10628
10635
10629
10636
function inferFromObjectTypes(source: Type, target: Type) {
10637
+ if (isGenericMappedType(source) && isGenericMappedType(target)) {
10638
+ // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer
10639
+ // from S to T and from X to Y.
10640
+ inferFromTypes(getConstraintTypeFromMappedType(<MappedType>source), getConstraintTypeFromMappedType(<MappedType>target));
10641
+ inferFromTypes(getTemplateTypeFromMappedType(<MappedType>source), getTemplateTypeFromMappedType(<MappedType>target));
10642
+ }
10630
10643
if (getObjectFlags(target) & ObjectFlags.Mapped) {
10631
10644
const constraintType = getConstraintTypeFromMappedType(<MappedType>target);
10632
10645
if (constraintType.flags & TypeFlags.Index) {
0 commit comments