Skip to content

Commit 114cd80

Browse files
authored
Merge pull request #26008 from ajafff/restbindingpattern
allow BindingPattern in BindingRestElement
2 parents c4d7992 + 2ea3123 commit 114cd80

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
@@ -29280,10 +29280,6 @@ namespace ts {
2928029280
}
2928129281
checkGrammarForDisallowedTrailingComma(elements, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
2928229282

29283-
if (node.name.kind === SyntaxKind.ArrayBindingPattern || node.name.kind === SyntaxKind.ObjectBindingPattern) {
29284-
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
29285-
}
29286-
2928729283
if (node.propertyName) {
2928829284
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_have_a_property_name);
2928929285
}

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)