Skip to content

Commit a3bac96

Browse files
committed
Fresh {} is subtype of object
1 parent 00c7c47 commit a3bac96

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18232,7 +18232,7 @@ namespace ts {
1823218232
// Since unions and intersections may reduce to `never`, we exclude them here.
1823318233
if (s & TypeFlags.Undefined && (!strictNullChecks && !(t & TypeFlags.UnionOrIntersection) || t & (TypeFlags.Undefined | TypeFlags.Void))) return true;
1823418234
if (s & TypeFlags.Null && (!strictNullChecks && !(t & TypeFlags.UnionOrIntersection) || t & TypeFlags.Null)) return true;
18235-
if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source))) return true;
18235+
if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & ObjectFlags.FreshLiteral))) return true;
1823618236
if (relation === assignableRelation || relation === comparableRelation) {
1823718237
if (s & TypeFlags.Any) return true;
1823818238
// Type number or any numeric literal type is assignable to any numeric enum type or any
@@ -18978,7 +18978,7 @@ namespace ts {
1897818978
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target as UnionType, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive));
1897918979
}
1898018980
if (target.flags & TypeFlags.Intersection) {
18981-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target as IntersectionType, reportErrors, IntersectionState.Target);
18981+
return typeRelatedToEachType(source, target as IntersectionType, reportErrors, IntersectionState.Target);
1898218982
}
1898318983
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
1898418984
// constraints of all non-primitive types in the source into a new intersection. We do this because the

0 commit comments

Comments
 (0)