@@ -167,7 +167,7 @@ module.exports = grammar({
167167 'module' ,
168168 optional ( 'rec' ) ,
169169 optional ( 'type' ) ,
170- field ( 'name' , $ . module_identifier ) ,
170+ field ( 'name' , choice ( $ . module_identifier , $ . _type_identifier ) ) ,
171171 optional ( seq (
172172 ':' ,
173173 field ( 'signature' , choice ( $ . block , $ . module_expression , $ . functor ) ) ,
@@ -185,6 +185,8 @@ module.exports = grammar({
185185 $ . extension_expression ,
186186 ) ,
187187
188+ module_unpack : $ => seq ( 'unpack' , $ . call_arguments ) ,
189+
188190 functor : $ => seq (
189191 field ( 'parameters' , $ . functor_parameters ) ,
190192 optional ( field ( 'return_module_type' , $ . module_type_annotation ) ) ,
@@ -277,6 +279,17 @@ module.exports = grammar({
277279 $ . object_type ,
278280 $ . generic_type ,
279281 $ . unit_type ,
282+ $ . module_pack_type ,
283+ ) ,
284+
285+ module_pack_type : $ => seq (
286+ 'module' ,
287+ '(' ,
288+ choice ( $ . module_identifier , $ . _type_identifier ) ,
289+ optional (
290+ seq ( 'with' , sep1 ( 'and' , seq ( 'type' , $ . _type_identifier , '=' , $ . _type_identifier ) ) )
291+ ) ,
292+ ')'
280293 ) ,
281294
282295 tuple_type : $ => prec . dynamic ( - 1 , seq (
@@ -429,6 +442,7 @@ module.exports = grammar({
429442 $ . record_pattern ,
430443 $ . array_pattern ,
431444 $ . list_pattern ,
445+ $ . module_unpack_pattern ,
432446 $ . unit
433447 ) ,
434448
@@ -475,7 +489,7 @@ module.exports = grammar({
475489 $ . pipe_expression ,
476490 $ . subscript_expression ,
477491 $ . member_expression ,
478- $ . module_destructuring_expression ,
492+ $ . module_pack_expression ,
479493 $ . extension_expression ,
480494 ) ,
481495
@@ -702,8 +716,12 @@ module.exports = grammar({
702716 ) ,
703717 ) ) ,
704718
705- module_destructuring_expression : $ => seq (
706- 'module' , '(' , choice ( $ . module_identifier , $ . module_identifier_path ) , ')'
719+ module_pack_expression : $ => seq (
720+ 'module' ,
721+ '(' ,
722+ choice ( $ . module_expression , $ . block ) ,
723+ optional ( seq ( ':' , $ . module_expression ) ) ,
724+ ')'
707725 ) ,
708726
709727 call_arguments : $ => seq (
@@ -772,7 +790,7 @@ module.exports = grammar({
772790
773791 type_parameter : $ => seq (
774792 'type' ,
775- $ . type_identifier ,
793+ repeat1 ( $ . type_identifier ) ,
776794 ) ,
777795
778796 _labeled_parameter_default_value : $ => seq (
@@ -886,6 +904,10 @@ module.exports = grammar({
886904 choice ( $ . value_identifier , $ . list_pattern , $ . array_pattern ) ,
887905 ) ,
888906
907+ module_unpack_pattern : $ => seq (
908+ 'module' , '(' , $ . module_identifier , ')' ,
909+ ) ,
910+
889911 _jsx_element : $ => choice ( $ . jsx_element , $ . jsx_self_closing_element ) ,
890912
891913 jsx_element : $ => seq (
@@ -1207,7 +1229,8 @@ module.exports = grammar({
12071229 $ . module_identifier_path ,
12081230 $ . module_type_of ,
12091231 $ . functor_use ,
1210- $ . module_type_constraint
1232+ $ . module_type_constraint ,
1233+ $ . module_unpack ,
12111234 ) ,
12121235
12131236 module_identifier_path : $ => prec . left ( seq (
0 commit comments