From b394182e1966ad8a0cd266e55675b1ea58263dd6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 14 Jun 2017 11:26:15 -0700 Subject: [PATCH] Improve excess property check for spread property Fall back to the assignment's declaration; don't use the property's valueDeclaration because that is not useful when the property comes from a spread. The fallback now happens when the property's valueDeclaration does not have the object literal's valueDeclaration as an ancestor. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4687856c605..4f68f19c617 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8955,7 +8955,8 @@ namespace ts { reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { - if (prop.valueDeclaration) { + const objectLiteralDeclaration = source.symbol && source.symbol.valueDeclaration; + if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration)) { errorNode = prop.valueDeclaration; } reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,