diff --git a/grammar.js b/grammar.js index 8448eb8..1a42add 100644 --- a/grammar.js +++ b/grammar.js @@ -259,20 +259,22 @@ module.exports = grammar({ optional('export'), 'type', optional('rec'), - $._type_declaration, + $._type_declaration ), _type_declaration: $ => seq( choice($.type_identifier, $.type_identifier_path), optional($.type_parameters), optional(seq( - choice('=', '+='), - optional('private'), - $._type, - repeat($.type_constraint), optional(seq('=', $._type)), - optional(alias($._type_declaration_and, $.type_declaration)), + optional(seq( + choice('=', '+='), + optional('private'), + $._type, + )), + repeat($.type_constraint), )), + optional(alias($._type_declaration_and, $.type_declaration)) ), _type_declaration_and: $ => seq( diff --git a/test/corpus/type_declarations.txt b/test/corpus/type_declarations.txt index 5335f1e..8ee8df2 100644 --- a/test/corpus/type_declarations.txt +++ b/test/corpus/type_declarations.txt @@ -5,13 +5,16 @@ Opaque type t type t' type \"type" +type t and b --- (source_file (type_declaration (type_identifier)) (type_declaration (type_identifier)) - (type_declaration (type_identifier))) + (type_declaration (type_identifier)) + (type_declaration (type_identifier) + (type_declaration (type_identifier)))) =========================================== Export @@ -530,6 +533,7 @@ Type constraint type t<'a> = 'a constraint 'a = int type decorator<'a, 'b> = 'a => 'b constraint 'a = int constraint 'b = _ => _ +type t<'a> constraint 'a = t --- @@ -553,4 +557,11 @@ type decorator<'a, 'b> = 'a => 'b constraint 'a = int constraint 'b = _ => _ (type_identifier) (function_type (function_type_parameters (type_identifier)) - (type_identifier))))) + (type_identifier)))) + + (type_declaration + (type_identifier) + (type_parameters (type_identifier)) + (type_constraint + (type_identifier) + (type_identifier))))