Skip to content

Commit 0e4e91f

Browse files
committed
fix: type constraint
1 parent 8f5c6de commit 0e4e91f

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

grammar.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,31 @@ module.exports = grammar({
259259
optional('export'),
260260
'type',
261261
optional('rec'),
262-
$._type_declaration,
262+
$._type_declaration
263263
),
264264

265265
_type_declaration: $ => seq(
266-
choice($.type_identifier, $.type_identifier_path),
267-
optional($.type_parameters),
268-
optional(seq(
269-
choice('=', '+='),
270-
optional('private'),
271-
$._type,
272-
repeat($.type_constraint),
273-
optional(seq('=', $._type)),
274-
optional(alias($._type_declaration_and, $.type_declaration)),
275-
)),
266+
choice(
267+
seq(
268+
$.type_identifier,
269+
optional($.type_parameters),
270+
optional(seq('=', $._type)),
271+
optional(seq(
272+
'=',
273+
optional('private'),
274+
$._type,
275+
)),
276+
repeat($.type_constraint),
277+
),
278+
seq(
279+
choice($.type_identifier, $.type_identifier_path),
280+
optional($.type_parameters),
281+
'+=',
282+
optional('private'),
283+
$.variant_type,
284+
)
285+
),
286+
optional(alias($._type_declaration_and, $.type_declaration))
276287
),
277288

278289
_type_declaration_and: $ => seq(

0 commit comments

Comments
 (0)