mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Error on non-identifier rest in destructuring assignment
This commit is contained in:
parent
ea309fe504
commit
9b2b2ca19b
@ -13941,7 +13941,12 @@ namespace ts {
|
||||
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), declarationNameToString(name));
|
||||
}
|
||||
}
|
||||
else if (property.kind !== SyntaxKind.SpreadAssignment) {
|
||||
else if (property.kind === SyntaxKind.SpreadAssignment) {
|
||||
if (property.expression.kind !== SyntaxKind.Identifier) {
|
||||
error(property.expression, Diagnostics.An_object_rest_element_must_be_an_identifier);
|
||||
}
|
||||
}
|
||||
else {
|
||||
error(property, Diagnostics.Property_assignment_expected);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1991,6 +1991,10 @@
|
||||
"category": "Error",
|
||||
"code": 2700
|
||||
},
|
||||
"An object rest element must be an identifier.": {
|
||||
"category": "Error",
|
||||
"code": 2701
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@ -328,8 +328,9 @@ namespace ts {
|
||||
bindingElements.push(p);
|
||||
}
|
||||
}
|
||||
else if (i === properties.length - 1 && p.kind === SyntaxKind.SpreadAssignment) {
|
||||
Debug.assert((p as SpreadAssignment).expression.kind === SyntaxKind.Identifier);
|
||||
else if (i === properties.length - 1 &&
|
||||
p.kind === SyntaxKind.SpreadAssignment &&
|
||||
p.expression.kind === SyntaxKind.Identifier) {
|
||||
if (bindingElements.length) {
|
||||
emitRestAssignment(bindingElements, value, location, target);
|
||||
bindingElements = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user