One more iteration

This commit is contained in:
Anders Hejlsberg 2019-04-17 13:58:05 -07:00
parent 3435451dcc
commit 50fdeccd7f

View file

@ -14960,9 +14960,11 @@ namespace ts {
}
// If no inferences can be made to K's constraint, infer from a union of the property types
// in the source to the template type X.
const indexInfo = getIndexInfoOfType(source, IndexKind.String) || getNonEnumNumberIndexInfo(source);
const sourcePropsType = indexInfo && indexInfo.type || getUnionType(map(getPropertiesOfType(source), getTypeOfSymbol));
inferFromTypes(sourcePropsType, getTemplateTypeFromMappedType(target));
const propTypes = map(getPropertiesOfType(source), getTypeOfSymbol);
const stringIndexType = getIndexTypeOfType(source, IndexKind.String);
const numberIndexInfo = getNonEnumNumberIndexInfo(source);
const numberIndexType = numberIndexInfo && numberIndexInfo.type;
inferFromTypes(getUnionType(append(append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
return true;
}
return false;