Skip to content

Commit bc2eb39

Browse files
authored
Merge pull request #189 from FnControlOption/destructuring-to-new-variable-with-default-value
Fix destructuring assignment to new variable with default value
2 parents 2c5b138 + cdab6a9 commit bc2eb39

File tree

5 files changed

+26412
-26583
lines changed

5 files changed

+26412
-26583
lines changed

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ module.exports = grammar({
11191119
pair_pattern: $ => seq(
11201120
field('key', $._property_name),
11211121
':',
1122-
field('value', $.pattern)
1122+
field('value', choice($.pattern, $.assignment_pattern))
11231123
),
11241124

11251125
_property_name: $ => choice(

src/grammar.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,8 +6189,17 @@
61896189
"type": "FIELD",
61906190
"name": "value",
61916191
"content": {
6192-
"type": "SYMBOL",
6193-
"name": "pattern"
6192+
"type": "CHOICE",
6193+
"members": [
6194+
{
6195+
"type": "SYMBOL",
6196+
"name": "pattern"
6197+
},
6198+
{
6199+
"type": "SYMBOL",
6200+
"name": "assignment_pattern"
6201+
}
6202+
]
61946203
}
61956204
}
61966205
]

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,10 @@
21932193
"multiple": false,
21942194
"required": true,
21952195
"types": [
2196+
{
2197+
"type": "assignment_pattern",
2198+
"named": true
2199+
},
21962200
{
21972201
"type": "pattern",
21982202
"named": true

0 commit comments

Comments
 (0)