mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-24 17:18:56 -05:00
Merge pull request #28429 from Microsoft/fixEmptyObjectIntersection
Fix empty object intersections
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user