Merge pull request #16530 from Microsoft/excess-property-check-error-span-for-spread-property

Improve excess property check error span for spread property
This commit is contained in:
Nathan Shively-Sanders
2017-06-14 16:16:20 -07:00
committed by GitHub
4 changed files with 55 additions and 2 deletions

View File

@@ -8955,7 +8955,9 @@ namespace ts {
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target));
}
else {
if (prop.valueDeclaration) {
// use the property's value declaration if the property is assigned inside the literal itself
const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations);
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,