File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,16 @@ module.exports = function defineGrammar(dialect) {
387
387
choice ( $ . _semicolon , $ . _function_signature_automatic_semicolon ) ,
388
388
) ,
389
389
390
+ decorator : $ => seq (
391
+ '@' ,
392
+ choice (
393
+ $ . identifier ,
394
+ alias ( $ . decorator_member_expression , $ . member_expression ) ,
395
+ alias ( $ . decorator_call_expression , $ . call_expression ) ,
396
+ alias ( $ . decorator_parenthesized_expression , $ . parenthesized_expression ) ,
397
+ ) ,
398
+ ) ,
399
+
390
400
decorator_call_expression : $ => prec ( 'call' , seq (
391
401
field ( 'function' , choice (
392
402
$ . identifier ,
@@ -396,6 +406,16 @@ module.exports = function defineGrammar(dialect) {
396
406
field ( 'arguments' , $ . arguments ) ,
397
407
) ) ,
398
408
409
+ decorator_parenthesized_expression : $ => seq (
410
+ '(' ,
411
+ choice (
412
+ $ . identifier ,
413
+ alias ( $ . decorator_member_expression , $ . member_expression ) ,
414
+ alias ( $ . decorator_call_expression , $ . call_expression ) ,
415
+ ) ,
416
+ ')' ,
417
+ ) ,
418
+
399
419
class_body : $ => seq (
400
420
'{' ,
401
421
repeat ( choice (
Original file line number Diff line number Diff line change @@ -1189,6 +1189,31 @@ abstract class Foo {
1189
1189
name: (type_identifier)
1190
1190
body: (class_body)))
1191
1191
1192
+ =======================================
1193
+ Decorator with parenthesized expression
1194
+ =======================================
1195
+
1196
+ class C {
1197
+ @(super.decorate)
1198
+ method2() { }
1199
+ }
1200
+
1201
+ ---
1202
+
1203
+ (program
1204
+ (class_declaration
1205
+ (type_identifier)
1206
+ (class_body
1207
+ (decorator
1208
+ (parenthesized_expression
1209
+ (member_expression
1210
+ (identifier)
1211
+ (property_identifier))))
1212
+ (method_definition
1213
+ (property_identifier)
1214
+ (formal_parameters)
1215
+ (statement_block)))))
1216
+
1192
1217
==================================
1193
1218
Index type queries
1194
1219
==================================
You can’t perform that action at this time.
0 commit comments