@@ -15438,7 +15438,7 @@ namespace ts {
1543815438 }
1543915439 else {
1544015440 if (target.flags & TypeFlags.Union) {
15441- result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), <UnionType>target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive));
15441+ result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), <UnionType>target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive), intersectionState & IntersectionState.ExcessCheck );
1544215442 }
1544315443 else if (target.flags & TypeFlags.Intersection) {
1544415444 result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target as IntersectionType, reportErrors, intersectionState & IntersectionState.ExcessCheck | IntersectionState.Target);
@@ -15655,7 +15655,7 @@ namespace ts {
1565515655 let result = Ternary.True;
1565615656 const sourceTypes = source.types;
1565715657 for (const sourceType of sourceTypes) {
15658- const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false);
15658+ const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false, IntersectionState.None );
1565915659 if (!related) {
1566015660 return Ternary.False;
1566115661 }
@@ -15664,20 +15664,20 @@ namespace ts {
1566415664 return result;
1566515665 }
1566615666
15667- function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
15667+ function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean, intersectionState: IntersectionState ): Ternary {
1566815668 const targetTypes = target.types;
1566915669 if (target.flags & TypeFlags.Union && containsType(targetTypes, source)) {
1567015670 return Ternary.True;
1567115671 }
1567215672 for (const type of targetTypes) {
15673- const related = isRelatedTo(source, type, /*reportErrors*/ false);
15673+ const related = isRelatedTo(source, type, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState );
1567415674 if (related) {
1567515675 return related;
1567615676 }
1567715677 }
1567815678 if (reportErrors) {
1567915679 const bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
15680- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
15680+ isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true, /*headMessage*/ undefined, intersectionState );
1568115681 }
1568215682 return Ternary.False;
1568315683 }
0 commit comments