Skip to content

Commit 116b265

Browse files
committed
Revert "someTypeRelatedToType now passes isIntersectionConstituent (#33213)"
This reverts commit 8ca36f3.
1 parent b3ec4ed commit 116b265

6 files changed

+10
-176
lines changed

src/compiler/checker.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -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), isIntersectionConstituent) :
12888+
someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) :
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, /*isIntersectionConstituent*/ true);
12926+
result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false);
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, isIntersectionConstituent: boolean): Ternary {
13205+
function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: 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, /*headMessage*/ undefined, isIntersectionConstituent);
13212+
const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1);
1321313213
if (related) {
1321413214
return related;
1321513215
}
@@ -21598,13 +21598,13 @@ namespace ts {
2159821598
checkMode: CheckMode,
2159921599
reportErrors: boolean,
2160021600
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
21601-
): ReadonlyArray<Diagnostic> | undefined {
21601+
) {
2160221602

2160321603
const errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } = { errors: undefined, skipLogging: true };
2160421604
if (isJsxOpeningLikeElement(node)) {
2160521605
if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
2160621606
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
21607-
return errorOutputContainer.errors || emptyArray;
21607+
return errorOutputContainer.errors || [];
2160821608
}
2160921609
return undefined;
2161021610
}
@@ -21619,7 +21619,7 @@ namespace ts {
2161921619
const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
2162021620
if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
2162121621
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
21622-
return errorOutputContainer.errors || emptyArray;
21622+
return errorOutputContainer.errors || [];
2162321623
}
2162421624
}
2162521625
const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
@@ -21637,7 +21637,7 @@ namespace ts {
2163721637
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
2163821638
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
2163921639
maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
21640-
return errorOutputContainer.errors || emptyArray;
21640+
return errorOutputContainer.errors || [];
2164121641
}
2164221642
}
2164321643
}
@@ -21647,7 +21647,7 @@ namespace ts {
2164721647
if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
2164821648
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
2164921649
maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
21650-
return errorOutputContainer.errors || emptyArray;
21650+
return errorOutputContainer.errors || [];
2165121651
}
2165221652
}
2165321653
return undefined;
@@ -22038,7 +22038,7 @@ namespace ts {
2203822038
}
2203922039
}
2204022040
else {
22041-
const allDiagnostics: (readonly DiagnosticRelatedInformation[])[] = [];
22041+
const allDiagnostics: DiagnosticRelatedInformation[][] = [];
2204222042
let max = 0;
2204322043
let min = Number.MAX_VALUE;
2204422044
let minIndex = 0;

tests/baselines/reference/quickIntersectionCheckCorrectlyCachesErrors.errors.txt

-20
This file was deleted.

tests/baselines/reference/quickIntersectionCheckCorrectlyCachesErrors.js

-42
This file was deleted.

tests/baselines/reference/quickIntersectionCheckCorrectlyCachesErrors.symbols

-48
This file was deleted.

tests/baselines/reference/quickIntersectionCheckCorrectlyCachesErrors.types

-41
This file was deleted.

tests/cases/compiler/quickIntersectionCheckCorrectlyCachesErrors.ts

-15
This file was deleted.

0 commit comments

Comments
 (0)