@@ -12880,7 +12880,7 @@ namespace ts {
12880
12880
// and we need to handle "each" relations before "some" relations for the same kind of type.
12881
12881
if (source.flags & TypeFlags.Union) {
12882
12882
result = relation === comparableRelation ?
12883
- someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) :
12883
+ someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), isIntersectionConstituent ) :
12884
12884
eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
12885
12885
}
12886
12886
else {
@@ -12918,7 +12918,7 @@ namespace ts {
12918
12918
//
12919
12919
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
12920
12920
// breaking the intersection apart.
12921
- result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false);
12921
+ result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true );
12922
12922
}
12923
12923
if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) {
12924
12924
if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) {
@@ -13197,14 +13197,14 @@ namespace ts {
13197
13197
return result;
13198
13198
}
13199
13199
13200
- function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary {
13200
+ function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, isIntersectionConstituent: boolean ): Ternary {
13201
13201
const sourceTypes = source.types;
13202
13202
if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) {
13203
13203
return Ternary.True;
13204
13204
}
13205
13205
const len = sourceTypes.length;
13206
13206
for (let i = 0; i < len; i++) {
13207
- const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1);
13207
+ const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent );
13208
13208
if (related) {
13209
13209
return related;
13210
13210
}
@@ -21574,13 +21574,13 @@ namespace ts {
21574
21574
checkMode: CheckMode,
21575
21575
reportErrors: boolean,
21576
21576
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
21577
- ) {
21577
+ ): ReadonlyArray<Diagnostic> | undefined {
21578
21578
21579
21579
const errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } = { errors: undefined, skipLogging: true };
21580
21580
if (isJsxOpeningLikeElement(node)) {
21581
21581
if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
21582
21582
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
21583
- return errorOutputContainer.errors || [] ;
21583
+ return errorOutputContainer.errors || emptyArray ;
21584
21584
}
21585
21585
return undefined;
21586
21586
}
@@ -21595,7 +21595,7 @@ namespace ts {
21595
21595
const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
21596
21596
if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
21597
21597
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
21598
- return errorOutputContainer.errors || [] ;
21598
+ return errorOutputContainer.errors || emptyArray ;
21599
21599
}
21600
21600
}
21601
21601
const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
@@ -21613,7 +21613,7 @@ namespace ts {
21613
21613
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
21614
21614
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
21615
21615
maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
21616
- return errorOutputContainer.errors || [] ;
21616
+ return errorOutputContainer.errors || emptyArray ;
21617
21617
}
21618
21618
}
21619
21619
}
@@ -21623,7 +21623,7 @@ namespace ts {
21623
21623
if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
21624
21624
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
21625
21625
maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
21626
- return errorOutputContainer.errors || [] ;
21626
+ return errorOutputContainer.errors || emptyArray ;
21627
21627
}
21628
21628
}
21629
21629
return undefined;
@@ -22014,7 +22014,7 @@ namespace ts {
22014
22014
}
22015
22015
}
22016
22016
else {
22017
- const allDiagnostics: DiagnosticRelatedInformation[][] = [];
22017
+ const allDiagnostics: (readonly DiagnosticRelatedInformation[]) [] = [];
22018
22018
let max = 0;
22019
22019
let min = Number.MAX_VALUE;
22020
22020
let minIndex = 0;
0 commit comments