diff --git a/packages/flow-parser/test/custom_ast_types.js b/packages/flow-parser/test/custom_ast_types.js index c29dc953928..6ce2cd382f4 100644 --- a/packages/flow-parser/test/custom_ast_types.js +++ b/packages/flow-parser/test/custom_ast_types.js @@ -249,10 +249,6 @@ function custom_ast_types(fork) { .bases('FlowType') .build('argument') .field('argument', def('FlowType')); - def('ReadOnlyTypeAnnotation') - .bases('FlowType') - .build('argument') - .field('argument', def('FlowType')); def('TypeParameter').field('usesExtendsBound', or(undefined, Boolean)); def('Variance').field( 'kind', diff --git a/src/parser/estree_translator.ml b/src/parser/estree_translator.ml index 7f87ab58036..22852c0ce25 100644 --- a/src/parser/estree_translator.ml +++ b/src/parser/estree_translator.ml @@ -1958,7 +1958,7 @@ with type t = Impl.t = struct loc [("operator", string operator); ("typeAnnotation", _type operand)] and read_only_type (loc, { Type.ReadOnly.argument; comments }) = - node ?comments "ReadOnlyTypeAnnotation" loc [("argument", _type argument)] + flow_type_operator loc comments "readonly" argument and tuple_type (loc, { Type.Tuple.elements; comments }) = node ?comments diff --git a/src/parser/test/flow/ts_syntax/invalid_readonly_type.tree.json b/src/parser/test/flow/ts_syntax/invalid_readonly_type.tree.json index 426b2a44dd0..4e7233cd844 100644 --- a/src/parser/test/flow/ts_syntax/invalid_readonly_type.tree.json +++ b/src/parser/test/flow/ts_syntax/invalid_readonly_type.tree.json @@ -23,10 +23,11 @@ }, "typeParameters":null, "right":{ - "type":"ReadOnlyTypeAnnotation", + "type":"TypeOperator", "loc":{"source":null,"start":{"line":1,"column":9},"end":{"line":1,"column":17}}, "range":[9,17], - "argument":{ + "operator":"readonly", + "typeAnnotation":{ "type":"AnyTypeAnnotation", "loc":{"source":null,"start":{"line":2,"column":0},"end":{"line":2,"column":0}}, "range":[18,18] diff --git a/src/parser/test/flow/ts_syntax/readonly_type.tree.json b/src/parser/test/flow/ts_syntax/readonly_type.tree.json index b19957ffaa2..2fb0392d7d2 100644 --- a/src/parser/test/flow/ts_syntax/readonly_type.tree.json +++ b/src/parser/test/flow/ts_syntax/readonly_type.tree.json @@ -17,10 +17,11 @@ }, "typeParameters":null, "right":{ - "type":"ReadOnlyTypeAnnotation", + "type":"TypeOperator", "loc":{"source":null,"start":{"line":1,"column":9},"end":{"line":1,"column":34}}, "range":[9,34], - "argument":{ + "operator":"readonly", + "typeAnnotation":{ "type":"TupleTypeAnnotation", "loc":{"source":null,"start":{"line":1,"column":18},"end":{"line":1,"column":34}}, "range":[18,34], @@ -53,10 +54,11 @@ }, "typeParameters":null, "right":{ - "type":"ReadOnlyTypeAnnotation", + "type":"TypeOperator", "loc":{"source":null,"start":{"line":2,"column":9},"end":{"line":2,"column":26}}, "range":[45,62], - "argument":{ + "operator":"readonly", + "typeAnnotation":{ "type":"ArrayTypeAnnotation", "loc":{"source":null,"start":{"line":2,"column":18},"end":{"line":2,"column":26}}, "range":[54,62], @@ -82,10 +84,11 @@ }, "typeParameters":null, "right":{ - "type":"ReadOnlyTypeAnnotation", + "type":"TypeOperator", "loc":{"source":null,"start":{"line":3,"column":9},"end":{"line":3,"column":24}}, "range":[73,88], - "argument":{ + "operator":"readonly", + "typeAnnotation":{ "type":"NumberTypeAnnotation", "loc":{"source":null,"start":{"line":3,"column":18},"end":{"line":3,"column":24}}, "range":[82,88]