mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Preserve actual empty object type intersection
This commit is contained in:
parent
59a8c94ff1
commit
55da2b9669
@ -9097,8 +9097,11 @@ namespace ts {
|
||||
if (flags & TypeFlags.Intersection) {
|
||||
return addTypesToIntersection(typeSet, includes, (<IntersectionType>type).types);
|
||||
}
|
||||
if (getObjectFlags(type) & ObjectFlags.Anonymous && isEmptyObjectType(type)) {
|
||||
includes |= TypeFlags.EmptyObject;
|
||||
if (isEmptyAnonymousObjectType(type)) {
|
||||
if (!(includes & TypeFlags.EmptyObject)) {
|
||||
includes |= TypeFlags.EmptyObject;
|
||||
typeSet.push(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
includes |= flags & ~TypeFlags.ConstructionFlags;
|
||||
@ -9229,8 +9232,8 @@ namespace ts {
|
||||
includes & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol) {
|
||||
removeRedundantPrimitiveTypes(typeSet, includes);
|
||||
}
|
||||
if (includes & TypeFlags.EmptyObject && !(includes & TypeFlags.Object)) {
|
||||
typeSet.push(emptyObjectType);
|
||||
if (includes & TypeFlags.EmptyObject && includes & TypeFlags.Object) {
|
||||
orderedRemoveItemAt(typeSet, findIndex(typeSet, isEmptyAnonymousObjectType));
|
||||
}
|
||||
if (typeSet.length === 0) {
|
||||
return unknownType;
|
||||
@ -11277,6 +11280,10 @@ namespace ts {
|
||||
false;
|
||||
}
|
||||
|
||||
function isEmptyAnonymousObjectType(type: Type) {
|
||||
return !!(getObjectFlags(type) & ObjectFlags.Anonymous) && isEmptyObjectType(type);
|
||||
}
|
||||
|
||||
function isEnumTypeRelatedTo(sourceSymbol: Symbol, targetSymbol: Symbol, errorReporter?: ErrorReporter) {
|
||||
if (sourceSymbol === targetSymbol) {
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user