@@ -21491,7 +21491,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21491
21491
eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), intersectionState);
21492
21492
}
21493
21493
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 );
21495
21495
}
21496
21496
if (target.flags & TypeFlags.Intersection) {
21497
21497
return typeRelatedToEachType(source, target as IntersectionType, reportErrors, IntersectionState.Target);
@@ -21525,7 +21525,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21525
21525
let result = Ternary.True;
21526
21526
const sourceTypes = source.types;
21527
21527
for (const sourceType of sourceTypes) {
21528
- const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false);
21528
+ const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false, IntersectionState.None );
21529
21529
if (!related) {
21530
21530
return Ternary.False;
21531
21531
}
@@ -21534,7 +21534,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21534
21534
return result;
21535
21535
}
21536
21536
21537
- function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
21537
+ function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean, intersectionState: IntersectionState ): Ternary {
21538
21538
const targetTypes = target.types;
21539
21539
if (target.flags & TypeFlags.Union) {
21540
21540
if (containsType(targetTypes, source)) {
@@ -21561,14 +21561,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21561
21561
}
21562
21562
const match = getMatchingUnionConstituentForType(target as UnionType, source);
21563
21563
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 );
21565
21565
if (related) {
21566
21566
return related;
21567
21567
}
21568
21568
}
21569
21569
}
21570
21570
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 );
21572
21572
if (related) {
21573
21573
return related;
21574
21574
}
@@ -21577,7 +21577,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21577
21577
// Elaborate only if we can find a best matching type in the target union
21578
21578
const bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
21579
21579
if (bestMatchingType) {
21580
- isRelatedTo(source, bestMatchingType, RecursionFlags.Target, /*reportErrors*/ true);
21580
+ isRelatedTo(source, bestMatchingType, RecursionFlags.Target, /*reportErrors*/ true, /*headMessage*/ undefined, intersectionState );
21581
21581
}
21582
21582
}
21583
21583
return Ternary.False;
0 commit comments