From 8a3a9c3be30814c40db1eefc96355600ef728d94 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 17 Nov 2022 14:07:38 -0300 Subject: [PATCH] support decorator with type Part of #141 --- grammar.js | 5 ++++- test/corpus/decorators.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/grammar.js b/grammar.js index 80e4ffa..1aab0d5 100644 --- a/grammar.js +++ b/grammar.js @@ -1073,7 +1073,10 @@ module.exports = grammar({ decorator_arguments: $ => seq( '(', - commaSept($.expression), + choice( + commaSept($.expression), + $.type_annotation + ), ')', ), diff --git a/test/corpus/decorators.txt b/test/corpus/decorators.txt index 72020d1..23ffc6b 100644 --- a/test/corpus/decorators.txt +++ b/test/corpus/decorators.txt @@ -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))))))))