Skip to content

Commit 95c3c56

Browse files
committed
Don't reduce intersections of form {...} & object
1 parent a25388d commit 95c3c56

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14838,7 +14838,6 @@ namespace ts {
1483814838
t.flags & TypeFlags.BigInt && includes & TypeFlags.BigIntLiteral ||
1483914839
t.flags & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol ||
1484014840
t.flags & TypeFlags.Void && includes & TypeFlags.Undefined ||
14841-
t.flags & TypeFlags.NonPrimitive && includes & TypeFlags.Object ||
1484214841
isEmptyAnonymousObjectType(t) && includes & TypeFlags.DefinitelyNonNullable;
1484314842
if (remove) {
1484414843
orderedRemoveItemAt(types, i);
@@ -15002,7 +15001,6 @@ namespace ts {
1500215001
includes & TypeFlags.BigInt && includes & TypeFlags.BigIntLiteral ||
1500315002
includes & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol ||
1500415003
includes & TypeFlags.Void && includes & TypeFlags.Undefined ||
15005-
includes & TypeFlags.NonPrimitive && includes & TypeFlags.Object ||
1500615004
includes & TypeFlags.IncludesEmptyObject && includes & TypeFlags.DefinitelyNonNullable) {
1500715005
removeRedundantSupertypes(typeSet, includes);
1500815006
}
@@ -25061,9 +25059,12 @@ namespace ts {
2506125059
if (!areTypesComparable(t, c)) {
2506225060
return neverType;
2506325061
}
25064-
if ((c.flags & TypeFlags.Primitive) && t.flags & TypeFlags.Object && !isEmptyAnonymousObjectType(t)) {
25062+
if (c.flags & TypeFlags.Primitive && t.flags & TypeFlags.Object && !isEmptyAnonymousObjectType(t)) {
2506525063
return isTypeSubtypeOf(c, t) ? c : neverType;
2506625064
}
25065+
if (c === globalFunctionType && t.flags & TypeFlags.NonPrimitive) {
25066+
return c;
25067+
}
2506725068
return getIntersectionType([t, c]);
2506825069
});
2506925070
});

0 commit comments

Comments
 (0)