File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -12526,17 +12526,23 @@ namespace ts {
12526
12526
return isEmptyObjectType(type) || !!(type.flags & (TypeFlags.Null | TypeFlags.Undefined | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.BigIntLike | TypeFlags.StringLike | TypeFlags.EnumLike | TypeFlags.NonPrimitive | TypeFlags.Index));
12527
12527
}
12528
12528
12529
+ function isSinglePropertyAnonymousObjectType(type: Type) {
12530
+ return !!(type.flags & TypeFlags.Object) &&
12531
+ !!(getObjectFlags(type) & ObjectFlags.Anonymous) &&
12532
+ (length(getPropertiesOfType(type)) === 1 || every(getPropertiesOfType(type), p => !!(p.flags & SymbolFlags.Optional)));
12533
+ }
12534
+
12529
12535
function tryMergeUnionOfObjectTypeAndEmptyObject(type: UnionType, readonly: boolean): Type | undefined {
12530
12536
if (type.types.length === 2) {
12531
12537
const firstType = type.types[0];
12532
12538
const secondType = type.types[1];
12533
12539
if (every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
12534
12540
return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
12535
12541
}
12536
- if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType)) {
12542
+ if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType) ) {
12537
12543
return getAnonymousPartialType(secondType);
12538
12544
}
12539
- if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType)) {
12545
+ if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType) ) {
12540
12546
return getAnonymousPartialType(firstType);
12541
12547
}
12542
12548
}
You can’t perform that action at this time.
0 commit comments