Skip to content

Commit 2ea3123

Browse files
committed
allow BindingPattern in BindingRestElement
Part of microsoft#6275
1 parent 3bfe91c commit 2ea3123

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29188,10 +29188,6 @@ namespace ts {
2918829188
}
2918929189
checkGrammarForDisallowedTrailingComma(elements, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
2919029190

29191-
if (node.name.kind === SyntaxKind.ArrayBindingPattern || node.name.kind === SyntaxKind.ObjectBindingPattern) {
29192-
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
29193-
}
29194-
2919529191
if (node.propertyName) {
2919629192
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_have_a_property_name);
2919729193
}

tests/baselines/reference/restElementWithBindingPattern.errors.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,9): error TS2501: A rest element cannot contain a binding pattern.
21
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,16): error TS2459: Type 'number[]' has no property 'b' and no string index signature.
32

43

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

0 commit comments

Comments
 (0)