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({
359359 optional ( '|' ) ,
360360 barSep1 ( $ . polyvar_declaration ) ,
361361 ']' ,
362- optional ( seq ( 'as' , $ . type_identifier ) )
362+ optional ( $ . as_aliasing_type )
363363 ) ) ,
364364
365365 polyvar_declaration : $ => prec . right (
@@ -393,15 +393,16 @@ module.exports = grammar({
393393 $ . type_annotation ,
394394 ) ,
395395
396- object_type : $ => seq (
396+ object_type : $ => prec . left ( seq (
397397 '{' ,
398398 choice (
399399 commaSep1t ( $ . _object_type_field ) ,
400400 seq ( '.' , commaSept ( $ . _object_type_field ) ) ,
401401 seq ( '..' , commaSept ( $ . _object_type_field ) ) ,
402402 ) ,
403403 '}' ,
404- ) ,
404+ optional ( $ . as_aliasing_type )
405+ ) ) ,
405406
406407 _object_type_field : $ => alias ( $ . object_type_field , $ . field ) ,
407408
@@ -732,6 +733,8 @@ module.exports = grammar({
732733 optional ( $ . type_annotation )
733734 ) ) ,
734735
736+ as_aliasing_type : $ => seq ( 'as' , $ . type_identifier ) ,
737+
735738 assert_expression : $ => prec . left ( seq ( 'assert' , $ . expression ) ) ,
736739
737740 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
243243 (polyvar_declaration (polyvar_identifier))
244244 (polyvar_declaration (polyvar_identifier))
245245 (polyvar_declaration (polyvar_identifier))
246- (type_identifier))))
246+ (as_aliasing_type ( type_identifier) ))))
247247
248248===========================================
249249Function
@@ -299,6 +299,7 @@ type t = {
299299 "my-field-two": string,
300300 ...rest
301301}
302+ type t<'a> = {.."name": string} as 'a
302303
303304---
304305
@@ -318,7 +319,13 @@ type t = {
318319 (object_type
319320 (field (property_identifier (string_fragment)) (type_identifier))
320321 (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)))))
322329
323330===========================================
324331Generic
You can’t perform that action at this time.
0 commit comments