@@ -12846,7 +12846,7 @@ namespace ts {
1284612846 // and we need to handle "each" relations before "some" relations for the same kind of type.
1284712847 if (source.flags & TypeFlags.Union) {
1284812848 result = relation === comparableRelation ?
12849- someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) :
12849+ someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), isIntersectionConstituent ) :
1285012850 eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
1285112851 }
1285212852 else {
@@ -12884,7 +12884,7 @@ namespace ts {
1288412884 //
1288512885 // - For a primitive type or type parameter (such as 'number = A & B') there is no point in
1288612886 // breaking the intersection apart.
12887- result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false);
12887+ result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true );
1288812888 }
1288912889 if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) {
1289012890 if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) {
@@ -13163,14 +13163,14 @@ namespace ts {
1316313163 return result;
1316413164 }
1316513165
13166- function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary {
13166+ function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, isIntersectionConstituent: boolean ): Ternary {
1316713167 const sourceTypes = source.types;
1316813168 if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) {
1316913169 return Ternary.True;
1317013170 }
1317113171 const len = sourceTypes.length;
1317213172 for (let i = 0; i < len; i++) {
13173- const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1);
13173+ const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent );
1317413174 if (related) {
1317513175 return related;
1317613176 }
@@ -21542,13 +21542,13 @@ namespace ts {
2154221542 checkMode: CheckMode,
2154321543 reportErrors: boolean,
2154421544 containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
21545- ) {
21545+ ): ReadonlyArray<Diagnostic> | undefined {
2154621546
2154721547 const errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } = { errors: undefined, skipLogging: true };
2154821548 if (isJsxOpeningLikeElement(node)) {
2154921549 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
2155021550 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
21551- return errorOutputContainer.errors || [] ;
21551+ return errorOutputContainer.errors || emptyArray ;
2155221552 }
2155321553 return undefined;
2155421554 }
@@ -21563,7 +21563,7 @@ namespace ts {
2156321563 const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
2156421564 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
2156521565 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
21566- return errorOutputContainer.errors || [] ;
21566+ return errorOutputContainer.errors || emptyArray ;
2156721567 }
2156821568 }
2156921569 const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
@@ -21581,7 +21581,7 @@ namespace ts {
2158121581 if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
2158221582 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
2158321583 maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
21584- return errorOutputContainer.errors || [] ;
21584+ return errorOutputContainer.errors || emptyArray ;
2158521585 }
2158621586 }
2158721587 }
@@ -21591,7 +21591,7 @@ namespace ts {
2159121591 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
2159221592 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
2159321593 maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
21594- return errorOutputContainer.errors || [] ;
21594+ return errorOutputContainer.errors || emptyArray ;
2159521595 }
2159621596 }
2159721597 return undefined;
@@ -21982,7 +21982,7 @@ namespace ts {
2198221982 }
2198321983 }
2198421984 else {
21985- const allDiagnostics: DiagnosticRelatedInformation[][] = [];
21985+ const allDiagnostics: (readonly DiagnosticRelatedInformation[]) [] = [];
2198621986 let max = 0;
2198721987 let min = Number.MAX_VALUE;
2198821988 let minIndex = 0;
0 commit comments