Merge pull request #29068 from Microsoft/noGenericEmptyObject

Generic types should never be considered empty objects
This commit is contained in:
Anders Hejlsberg
2018-12-17 15:59:42 -08:00
committed by GitHub
5 changed files with 123 additions and 2 deletions

View File

@@ -11386,7 +11386,7 @@ namespace ts {
}
function isEmptyObjectType(type: Type): boolean {
return type.flags & TypeFlags.Object ? isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>type)) :
return type.flags & TypeFlags.Object ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>type)) :
type.flags & TypeFlags.NonPrimitive ? true :
type.flags & TypeFlags.Union ? some((<UnionType>type).types, isEmptyObjectType) :
type.flags & TypeFlags.Intersection ? every((<UnionType>type).types, isEmptyObjectType) :
@@ -12361,7 +12361,7 @@ namespace ts {
}
else {
// An empty object type is related to any mapped type that includes a '?' modifier.
if (isPartialMappedType(target) && !isGenericMappedType(source) && isEmptyObjectType(source)) {
if (isPartialMappedType(target) && isEmptyObjectType(source)) {
return Ternary.True;
}
if (isGenericMappedType(target)) {