Skip to content

Commit

Permalink
support decorator with type
Browse files Browse the repository at this point in the history
  • Loading branch information
aspeddro committed Nov 17, 2022
1 parent 39720a2 commit 8a3a9c3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,10 @@ module.exports = grammar({

decorator_arguments: $ => seq(
'(',
commaSept($.expression),
choice(
commaSept($.expression),
$.type_annotation
),
')',
),

Expand Down
28 changes: 28 additions & 0 deletions test/corpus/decorators.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,31 @@ and bar = {bar: int}
(decorator (decorator_identifier))
(type_identifier)
(record_type (record_type_field (property_identifier) (type_annotation (type_identifier))))))))

============================================
Decorator with type
============================================

@react.component(:sharedProps)
let make = (~x, ~y) => React.string(x ++ y)

---

(source_file
(decorated
(decorator
(decorator_identifier)
(decorator_arguments
(type_annotation (type_identifier))))
(let_binding
(value_identifier)
(function
(formal_parameters
(parameter (labeled_parameter (value_identifier)))
(parameter (labeled_parameter (value_identifier))))
(call_expression
(value_identifier_path
(module_identifier) (value_identifier))
(arguments
(binary_expression
(value_identifier) (value_identifier))))))))

0 comments on commit 8a3a9c3

Please sign in to comment.