Unknown properties are assignable to Object unions

For the last week or so they have been treated as excess properties when
assigning to a union type containing Object, but not when assigning directly
to Object type.
This commit is contained in:
Nathan Shively-Sanders 2017-04-18 14:56:11 -07:00
parent 2ca1de514a
commit adefdc7953

View file

@ -8708,7 +8708,7 @@ namespace ts {
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
if ((relation === assignableRelation || relation === comparableRelation) &&
(target === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
(isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
return false;
}
for (const prop of getPropertiesOfObjectType(source)) {