From 17d996e6b216c0f993ea47d7270b89d7fff5bf47 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Sep 2020 11:45:16 -0700 Subject: [PATCH] Revert 7181c2af --- src/compiler/checker.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5658109668c..dc09e87a4e0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14393,12 +14393,6 @@ namespace ts { return isEmptyObjectType(type) || !!(type.flags & (TypeFlags.Null | TypeFlags.Undefined | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.BigIntLike | TypeFlags.StringLike | TypeFlags.EnumLike | TypeFlags.NonPrimitive | TypeFlags.Index)); } - function isSinglePropertyAnonymousObjectType(type: Type) { - return !!(type.flags & TypeFlags.Object) && - !!(getObjectFlags(type) & ObjectFlags.Anonymous) && - (length(getPropertiesOfType(type)) === 1 || every(getPropertiesOfType(type), p => !!(p.flags & SymbolFlags.Optional))); - } - function tryMergeUnionOfObjectTypeAndEmptyObject(type: UnionType, readonly: boolean): Type | undefined { if (type.types.length === 2) { const firstType = type.types[0]; @@ -14406,10 +14400,10 @@ namespace ts { if (every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType; } - if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) { + if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType)) { return getAnonymousPartialType(secondType); } - if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) { + if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType)) { return getAnonymousPartialType(firstType); } }