Skip to content

Commit 670946d

Browse files
committed
Propagate intersectionState in typeRelatedToSomeType
1 parent b76b4c2 commit 670946d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/compiler/checker.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -21491,7 +21491,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2149121491
eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), intersectionState);
2149221492
}
2149321493
if (target.flags & TypeFlags.Union) {
21494-
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target as UnionType, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive));
21494+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target as UnionType, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive), intersectionState);
2149521495
}
2149621496
if (target.flags & TypeFlags.Intersection) {
2149721497
return typeRelatedToEachType(source, target as IntersectionType, reportErrors, IntersectionState.Target);
@@ -21525,7 +21525,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2152521525
let result = Ternary.True;
2152621526
const sourceTypes = source.types;
2152721527
for (const sourceType of sourceTypes) {
21528-
const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false);
21528+
const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false, IntersectionState.None);
2152921529
if (!related) {
2153021530
return Ternary.False;
2153121531
}
@@ -21534,7 +21534,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2153421534
return result;
2153521535
}
2153621536

21537-
function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
21537+
function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
2153821538
const targetTypes = target.types;
2153921539
if (target.flags & TypeFlags.Union) {
2154021540
if (containsType(targetTypes, source)) {
@@ -21561,14 +21561,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2156121561
}
2156221562
const match = getMatchingUnionConstituentForType(target as UnionType, source);
2156321563
if (match) {
21564-
const related = isRelatedTo(source, match, RecursionFlags.Target, /*reportErrors*/ false);
21564+
const related = isRelatedTo(source, match, RecursionFlags.Target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
2156521565
if (related) {
2156621566
return related;
2156721567
}
2156821568
}
2156921569
}
2157021570
for (const type of targetTypes) {
21571-
const related = isRelatedTo(source, type, RecursionFlags.Target, /*reportErrors*/ false);
21571+
const related = isRelatedTo(source, type, RecursionFlags.Target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
2157221572
if (related) {
2157321573
return related;
2157421574
}
@@ -21577,7 +21577,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2157721577
// Elaborate only if we can find a best matching type in the target union
2157821578
const bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
2157921579
if (bestMatchingType) {
21580-
isRelatedTo(source, bestMatchingType, RecursionFlags.Target, /*reportErrors*/ true);
21580+
isRelatedTo(source, bestMatchingType, RecursionFlags.Target, /*reportErrors*/ true, /*headMessage*/ undefined, intersectionState);
2158121581
}
2158221582
}
2158321583
return Ternary.False;

0 commit comments

Comments
 (0)