@@ -8328,8 +8328,11 @@ namespace ts {
8328
8328
!t.numberIndexInfo;
8329
8329
}
8330
8330
8331
- function isEmptyObjectType(type: Type) {
8332
- return type.flags & TypeFlags.Object && isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>type));
8331
+ function isEmptyObjectType(type: Type): boolean {
8332
+ return type.flags & TypeFlags.Object ? isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>type)) :
8333
+ type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isEmptyObjectType) :
8334
+ type.flags & TypeFlags.Intersection ? !forEach((<UnionType>type).types, t => !isEmptyObjectType(t)) :
8335
+ false;
8333
8336
}
8334
8337
8335
8338
function isEnumTypeRelatedTo(source: EnumType, target: EnumType, errorReporter?: ErrorReporter) {
@@ -8645,14 +8648,8 @@ namespace ts {
8645
8648
function isKnownProperty(type: Type, name: string, isComparingJsxAttributes: boolean): boolean {
8646
8649
if (type.flags & TypeFlags.Object) {
8647
8650
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
8648
- if ((relation === assignableRelation || relation === comparableRelation) &&
8649
- (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) {
8650
- return true;
8651
- }
8652
- else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) {
8653
- return true;
8654
- }
8655
- else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) {
8651
+ if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) ||
8652
+ getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
8656
8653
// For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known.
8657
8654
return true;
8658
8655
}
@@ -8670,6 +8667,10 @@ namespace ts {
8670
8667
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
8671
8668
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
8672
8669
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
8670
+ if ((relation === assignableRelation || relation === comparableRelation) &&
8671
+ (target === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
8672
+ return false;
8673
+ }
8673
8674
for (const prop of getPropertiesOfObjectType(source)) {
8674
8675
if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) {
8675
8676
if (reportErrors) {
0 commit comments