Address PR comments

This commit is contained in:
Nathan Shively-Sanders
2017-02-13 12:54:58 -08:00
parent 1c7628e653
commit 11929e33ed

View File

@@ -7771,18 +7771,14 @@ namespace ts {
if (target.flags & TypeFlags.Union && containsType(targetTypes, source)) {
return Ternary.True;
}
const discriminantType = findMatchingDiscriminantType(source, target);
if (discriminantType) {
return isRelatedTo(source, discriminantType, reportErrors);
}
const len = targetTypes.length;
for (let i = 0; i < len; i++) {
const related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1);
for (const type of targetTypes) {
const related = isRelatedTo(source, type, /*reportErrors*/ false);
if (related) {
return related;
}
}
const discriminantType = findMatchingDiscriminantType(source, target);
isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], reportErrors);
return Ternary.False;
}