Skip to content

allow BindingPattern in BindingRestElement #26008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29188,10 +29188,6 @@ namespace ts {
}
checkGrammarForDisallowedTrailingComma(elements, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);

if (node.name.kind === SyntaxKind.ArrayBindingPattern || node.name.kind === SyntaxKind.ObjectBindingPattern) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this never checked BindingRestProperty because that has a parse error: https://agentcooper.github.io/typescript-play/#code/DYUwLgBA3gdHUF8EQLzQQGmnGBtAusmogNxA

return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
}

if (node.propertyName) {
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_have_a_property_name);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,9): error TS2501: A rest element cannot contain a binding pattern.
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,16): error TS2459: Type 'number[]' has no property 'b' and no string index signature.


==== tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts (2 errors) ====
==== tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts (1 errors) ====
var [...{0: a, b }] = [0, 1];
~~~~~~~~~~
!!! error TS2501: A rest element cannot contain a binding pattern.
~
!!! error TS2459: Type 'number[]' has no property 'b' and no string index signature.