@@ -12846,7 +12846,7 @@ namespace ts {
12846
12846
// and we need to handle "each" relations before "some" relations for the same kind of type.
12847
12847
if (source.flags & TypeFlags.Union) {
12848
12848
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 ) :
12850
12850
eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
12851
12851
}
12852
12852
else {
@@ -12884,7 +12884,7 @@ namespace ts {
12884
12884
//
12885
12885
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
12886
12886
// breaking the intersection apart.
12887
- result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false);
12887
+ result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true );
12888
12888
}
12889
12889
if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) {
12890
12890
if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) {
@@ -13163,14 +13163,14 @@ namespace ts {
13163
13163
return result;
13164
13164
}
13165
13165
13166
- function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary {
13166
+ function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, isIntersectionConstituent: boolean ): Ternary {
13167
13167
const sourceTypes = source.types;
13168
13168
if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) {
13169
13169
return Ternary.True;
13170
13170
}
13171
13171
const len = sourceTypes.length;
13172
13172
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 );
13174
13174
if (related) {
13175
13175
return related;
13176
13176
}
@@ -21542,13 +21542,13 @@ namespace ts {
21542
21542
checkMode: CheckMode,
21543
21543
reportErrors: boolean,
21544
21544
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
21545
- ) {
21545
+ ): ReadonlyArray<Diagnostic> | undefined {
21546
21546
21547
21547
const errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } = { errors: undefined, skipLogging: true };
21548
21548
if (isJsxOpeningLikeElement(node)) {
21549
21549
if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
21550
21550
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
21551
- return errorOutputContainer.errors || [] ;
21551
+ return errorOutputContainer.errors || emptyArray ;
21552
21552
}
21553
21553
return undefined;
21554
21554
}
@@ -21563,7 +21563,7 @@ namespace ts {
21563
21563
const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
21564
21564
if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
21565
21565
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
21566
- return errorOutputContainer.errors || [] ;
21566
+ return errorOutputContainer.errors || emptyArray ;
21567
21567
}
21568
21568
}
21569
21569
const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
@@ -21581,7 +21581,7 @@ namespace ts {
21581
21581
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
21582
21582
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
21583
21583
maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
21584
- return errorOutputContainer.errors || [] ;
21584
+ return errorOutputContainer.errors || emptyArray ;
21585
21585
}
21586
21586
}
21587
21587
}
@@ -21591,7 +21591,7 @@ namespace ts {
21591
21591
if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
21592
21592
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
21593
21593
maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
21594
- return errorOutputContainer.errors || [] ;
21594
+ return errorOutputContainer.errors || emptyArray ;
21595
21595
}
21596
21596
}
21597
21597
return undefined;
@@ -21982,7 +21982,7 @@ namespace ts {
21982
21982
}
21983
21983
}
21984
21984
else {
21985
- const allDiagnostics: DiagnosticRelatedInformation[][] = [];
21985
+ const allDiagnostics: (readonly DiagnosticRelatedInformation[]) [] = [];
21986
21986
let max = 0;
21987
21987
let min = Number.MAX_VALUE;
21988
21988
let minIndex = 0;
0 commit comments