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.
This commit is contained in:
Nathan Shively-Sanders
2017-06-14 11:26:15 -07:00
parent fbe002a595
commit 8680768478

View File

@@ -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,