mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user