@@ -22999,11 +22999,16 @@ namespace ts {
2299922999 }
2300023000 }
2300123001
23002- // If the candidate type is a subtype of the target type, narrow to the candidate type,
23003- // if the target type is a subtype of the candidate type, narrow to the target type,
23004- // otherwise, narrow to an intersection of the two types.
23005- return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
23006- }
23002+ // If the candidate type is a subtype of the target type, narrow to the candidate type.
23003+ // Otherwise, if the target type is assignable to the candidate type, keep the target type.
23004+ // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate
23005+ // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
23006+ // two types.
23007+ return isTypeSubtypeOf(candidate, type) ? candidate :
23008+ isTypeAssignableTo(type, candidate) ? type :
23009+ isTypeAssignableTo(candidate, type) ? candidate :
23010+ getIntersectionType([type, candidate]);
23011+ }
2300723012
2300823013 function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
2300923014 if (hasMatchingArgument(callExpression, reference)) {
0 commit comments