File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -359,7 +359,7 @@ module.exports = grammar({
359
359
optional ( '|' ) ,
360
360
barSep1 ( $ . polyvar_declaration ) ,
361
361
']' ,
362
- optional ( seq ( 'as' , $ . type_identifier ) )
362
+ optional ( $ . as_aliasing_type )
363
363
) ) ,
364
364
365
365
polyvar_declaration : $ => prec . right (
@@ -393,15 +393,16 @@ module.exports = grammar({
393
393
$ . type_annotation ,
394
394
) ,
395
395
396
- object_type : $ => seq (
396
+ object_type : $ => prec . left ( seq (
397
397
'{' ,
398
398
choice (
399
399
commaSep1t ( $ . _object_type_field ) ,
400
400
seq ( '.' , commaSept ( $ . _object_type_field ) ) ,
401
401
seq ( '..' , commaSept ( $ . _object_type_field ) ) ,
402
402
) ,
403
403
'}' ,
404
- ) ,
404
+ optional ( $ . as_aliasing_type )
405
+ ) ) ,
405
406
406
407
_object_type_field : $ => alias ( $ . object_type_field , $ . field ) ,
407
408
@@ -732,6 +733,8 @@ module.exports = grammar({
732
733
optional ( $ . type_annotation )
733
734
) ) ,
734
735
736
+ as_aliasing_type : $ => seq ( 'as' , $ . type_identifier ) ,
737
+
735
738
assert_expression : $ => prec . left ( seq ( 'assert' , $ . expression ) ) ,
736
739
737
740
call_expression : $ => prec ( 'call' , seq (
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ type foo<'a> = [> #Blue | #DeepBlue | #LightBlue ] as 'a
243
243
(polyvar_declaration (polyvar_identifier))
244
244
(polyvar_declaration (polyvar_identifier))
245
245
(polyvar_declaration (polyvar_identifier))
246
- (type_identifier))))
246
+ (as_aliasing_type ( type_identifier) ))))
247
247
248
248
===========================================
249
249
Function
@@ -299,6 +299,7 @@ type t = {
299
299
"my-field-two": string,
300
300
...rest
301
301
}
302
+ type t<'a> = {.."name": string} as 'a
302
303
303
304
---
304
305
@@ -318,7 +319,13 @@ type t = {
318
319
(object_type
319
320
(field (property_identifier (string_fragment)) (type_identifier))
320
321
(field (property_identifier (string_fragment)) (type_identifier))
321
- (field (type_identifier)))))
322
+ (field (type_identifier))))
323
+ (type_declaration
324
+ (type_identifier)
325
+ (type_parameters (type_identifier))
326
+ (object_type
327
+ (field (property_identifier (string_fragment)) (type_identifier))
328
+ (as_aliasing_type (type_identifier)))))
322
329
323
330
===========================================
324
331
Generic
You can’t perform that action at this time.
0 commit comments