Skip to content

Commit 8a3a9c3

Browse files
committed
support decorator with type
Part of rescript-lang#141
1 parent 39720a2 commit 8a3a9c3

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

grammar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,10 @@ module.exports = grammar({
10731073

10741074
decorator_arguments: $ => seq(
10751075
'(',
1076-
commaSept($.expression),
1076+
choice(
1077+
commaSept($.expression),
1078+
$.type_annotation
1079+
),
10771080
')',
10781081
),
10791082

test/corpus/decorators.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,31 @@ and bar = {bar: int}
114114
(decorator (decorator_identifier))
115115
(type_identifier)
116116
(record_type (record_type_field (property_identifier) (type_annotation (type_identifier))))))))
117+
118+
============================================
119+
Decorator with type
120+
============================================
121+
122+
@react.component(:sharedProps)
123+
let make = (~x, ~y) => React.string(x ++ y)
124+
125+
---
126+
127+
(source_file
128+
(decorated
129+
(decorator
130+
(decorator_identifier)
131+
(decorator_arguments
132+
(type_annotation (type_identifier))))
133+
(let_binding
134+
(value_identifier)
135+
(function
136+
(formal_parameters
137+
(parameter (labeled_parameter (value_identifier)))
138+
(parameter (labeled_parameter (value_identifier))))
139+
(call_expression
140+
(value_identifier_path
141+
(module_identifier) (value_identifier))
142+
(arguments
143+
(binary_expression
144+
(value_identifier) (value_identifier))))))))

0 commit comments

Comments
 (0)