Skip to content

Commit 37d539d

Browse files
committed
Treat intersections of only objects as a single object in relations
1 parent dd6811f commit 37d539d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15363,7 +15363,9 @@ namespace ts {
1536315363
//
1536415364
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
1536515365
// breaking the intersection apart.
15366-
result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, IntersectionState.Source);
15366+
if (!isNonGenericObjectType(target) || !every((<IntersectionType>source).types, isNonGenericObjectType)) {
15367+
result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false, IntersectionState.Source);
15368+
}
1536715369
}
1536815370
if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) {
1536915371
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {

0 commit comments

Comments
 (0)