@@ -12885,7 +12885,7 @@ namespace ts {
1288512885 // and we need to handle "each" relations before "some" relations for the same kind of type.
1288612886 if (source.flags & TypeFlags.Union) {
1288712887 result = relation === comparableRelation ?
12888- someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) :
12888+ someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), isIntersectionConstituent ) :
1288912889 eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
1289012890 }
1289112891 else {
@@ -12923,7 +12923,7 @@ namespace ts {
1292312923 //
1292412924 // - For a primitive type or type parameter (such as 'number = A & B') there is no point in
1292512925 // breaking the intersection apart.
12926- result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false);
12926+ result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true );
1292712927 }
1292812928 if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) {
1292912929 if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) {
@@ -13202,14 +13202,14 @@ namespace ts {
1320213202 return result;
1320313203 }
1320413204
13205- function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary {
13205+ function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, isIntersectionConstituent: boolean ): Ternary {
1320613206 const sourceTypes = source.types;
1320713207 if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) {
1320813208 return Ternary.True;
1320913209 }
1321013210 const len = sourceTypes.length;
1321113211 for (let i = 0; i < len; i++) {
13212- const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1);
13212+ const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent );
1321313213 if (related) {
1321413214 return related;
1321513215 }
@@ -21578,13 +21578,13 @@ namespace ts {
2157821578 checkMode: CheckMode,
2157921579 reportErrors: boolean,
2158021580 containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
21581- ) {
21581+ ): ReadonlyArray<Diagnostic> | undefined {
2158221582
2158321583 const errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } = { errors: undefined, skipLogging: true };
2158421584 if (isJsxOpeningLikeElement(node)) {
2158521585 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
2158621586 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
21587- return errorOutputContainer.errors || [] ;
21587+ return errorOutputContainer.errors || emptyArray ;
2158821588 }
2158921589 return undefined;
2159021590 }
@@ -21599,7 +21599,7 @@ namespace ts {
2159921599 const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
2160021600 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
2160121601 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
21602- return errorOutputContainer.errors || [] ;
21602+ return errorOutputContainer.errors || emptyArray ;
2160321603 }
2160421604 }
2160521605 const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
@@ -21617,7 +21617,7 @@ namespace ts {
2161721617 if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
2161821618 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
2161921619 maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
21620- return errorOutputContainer.errors || [] ;
21620+ return errorOutputContainer.errors || emptyArray ;
2162121621 }
2162221622 }
2162321623 }
@@ -21627,7 +21627,7 @@ namespace ts {
2162721627 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
2162821628 Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
2162921629 maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
21630- return errorOutputContainer.errors || [] ;
21630+ return errorOutputContainer.errors || emptyArray ;
2163121631 }
2163221632 }
2163321633 return undefined;
@@ -22018,7 +22018,7 @@ namespace ts {
2201822018 }
2201922019 }
2202022020 else {
22021- const allDiagnostics: DiagnosticRelatedInformation[][] = [];
22021+ const allDiagnostics: (readonly DiagnosticRelatedInformation[]) [] = [];
2202222022 let max = 0;
2202322023 let min = Number.MAX_VALUE;
2202422024 let minIndex = 0;
0 commit comments