Skip to content

Commit f269f42

Browse files
committed
Less aggressive reduction in second pass union/intersection checks
1 parent a65794c commit f269f42

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11823,11 +11823,6 @@ namespace ts {
1182311823
return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
1182411824
}
1182511825

11826-
function hasStructuredOrInstantiableConstraint(type: Type) {
11827-
const constraint = type.flags & TypeFlags.Instantiable ? getConstraintOfType(type) : undefined;
11828-
return constraint && !!(constraint.flags & TypeFlags.StructuredOrInstantiable);
11829-
}
11830-
1183111826
function isUnionContainingMultipleObjectLikeTypes(type: Type) {
1183211827
return !!(type.flags & TypeFlags.Union) &&
1183311828
countWhere((type as UnionType).types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.Substitution))) >= 2;
@@ -18365,10 +18360,10 @@ namespace ts {
1836518360
// (1) Source is an intersection of object types { a } & { b } and target is an object type { a, b }.
1836618361
// (2) Source is an object type { a, b: boolean } and target is a union { a, b: true } | { a, b: false }.
1836718362
// (3) Source is an intersection { a } & { b: boolean } and target is a union { a, b: true } | { a, b: false }.
18368-
// (4) Source is an instantiable type with a union constraint and target is a union.
18363+
// (4) Source is an instantiable type with a union or intersection constraint and target is a union or intersection.
1836918364
if (!result && (source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Object ||
18370-
(source.flags & (TypeFlags.Object | TypeFlags.Intersection) && isUnionContainingMultipleObjectLikeTypes(target)) ||
18371-
(target.flags & TypeFlags.Union && hasStructuredOrInstantiableConstraint(source)))) {
18365+
source.flags & (TypeFlags.Object | TypeFlags.Intersection) && isUnionContainingMultipleObjectLikeTypes(target) ||
18366+
source.flags & TypeFlags.Instantiable && target.flags & TypeFlags.UnionOrIntersection)) {
1837218367
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
1837318368
resetErrorInfo(saveErrorInfo);
1837418369
}

0 commit comments

Comments
 (0)