@@ -8668,11 +8668,14 @@ namespace ts {
8668
8668
function inferFromObjectTypes(source: Type, target: Type) {
8669
8669
if (getObjectFlags(target) & ObjectFlags.Mapped) {
8670
8670
const constraintType = getConstraintTypeFromMappedType(<MappedType>target);
8671
- if (getObjectFlags(source) & ObjectFlags.Mapped) {
8672
- // We're inferring from a mapped type to a mapped type, so simply infer from constraint type to
8673
- // constraint type and from template type to template type.
8674
- inferFromTypes(getConstraintTypeFromMappedType(<MappedType>source), constraintType);
8675
- inferFromTypes(getTemplateTypeFromMappedType(<MappedType>source), getTemplateTypeFromMappedType(<MappedType>target));
8671
+ if (constraintType.flags & TypeFlags.Index) {
8672
+ // We're inferring from some source type S to an isomorphic mapped type { [P in keyof T]: X },
8673
+ // where T is a type parameter. Use inferTypeForIsomorphicMappedType to infer a suitable source
8674
+ // type and then infer from that type to T.
8675
+ const index = indexOf(typeParameters, (<IndexType>constraintType).type);
8676
+ if (index >= 0 && !typeInferences[index].isFixed) {
8677
+ inferFromTypes(inferTypeForIsomorphicMappedType(source, <MappedType>target), typeParameters[index]);
8678
+ }
8676
8679
return;
8677
8680
}
8678
8681
if (constraintType.flags & TypeFlags.TypeParameter) {
@@ -8682,14 +8685,11 @@ namespace ts {
8682
8685
inferFromTypes(getUnionType(map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(<MappedType>target));
8683
8686
return;
8684
8687
}
8685
- if (constraintType.flags & TypeFlags.Index) {
8686
- // We're inferring from some source type S to an isomorphic mapped type { [P in keyof T]: X },
8687
- // where T is a type parameter. Use inferTypeForIsomorphicMappedType to infer a suitable source
8688
- // type and then infer from that type to T.
8689
- const index = indexOf(typeParameters, (<IndexType>constraintType).type);
8690
- if (index >= 0 && !typeInferences[index].isFixed) {
8691
- inferFromTypes(inferTypeForIsomorphicMappedType(source, <MappedType>target), typeParameters[index]);
8692
- }
8688
+ if (getObjectFlags(source) & ObjectFlags.Mapped) {
8689
+ // We're inferring from a mapped type to a mapped type, so simply infer from constraint type to
8690
+ // constraint type and from template type to template type.
8691
+ inferFromTypes(getConstraintTypeFromMappedType(<MappedType>source), constraintType);
8692
+ inferFromTypes(getTemplateTypeFromMappedType(<MappedType>source), getTemplateTypeFromMappedType(<MappedType>target));
8693
8693
return;
8694
8694
}
8695
8695
}
0 commit comments