Properly handle contravariant inferences in inferReverseMappedType

This commit is contained in:
Anders Hejlsberg 2018-01-18 17:15:48 -08:00
parent ebbb3a4dc4
commit 5bb8d2a590

View File

@ -11029,7 +11029,9 @@ namespace ts {
const templateType = getTemplateTypeFromMappedType(target);
const inference = createInferenceInfo(typeParameter);
inferTypes([inference], sourceType, templateType);
return inference.candidates ? getUnionType(inference.candidates, UnionReduction.Subtype) : emptyObjectType;
return inference.candidates ? getUnionType(inference.candidates, UnionReduction.Subtype) :
inference.contraCandidates ? getCommonSubtype(inference.contraCandidates) :
emptyObjectType;
}
function getUnmatchedProperty(source: Type, target: Type, requireOptionalProperties: boolean) {