emit error on destructuring of rest property (#29609)

Fixes: #26005
This commit is contained in:
Klaus Meinhardt
2019-04-25 22:33:49 +02:00
committed by Ryan Cavanaugh
parent dc7c9bad3d
commit b45df892a8
6 changed files with 97 additions and 0 deletions

View File

@@ -31186,6 +31186,13 @@ namespace ts {
for (const prop of node.properties) {
if (prop.kind === SyntaxKind.SpreadAssignment) {
if (inDestructuring) {
// a rest property cannot be destructured any further
const expression = skipParentheses(prop.expression);
if (isArrayLiteralExpression(expression) || isObjectLiteralExpression(expression)) {
return grammarErrorOnNode(prop.expression, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
}
}
continue;
}
const name = prop.name;