hermes-parser 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,8 +40,8 @@ type HermesParserWASM = $ReadOnly<{
40
40
  (
41
41
  'hermesParse',
42
42
  'number',
43
- ['number', 'number', 'number', 'number', 'number'],
44
- ): (number, number, CBoolean, CBoolean, CBoolean) => number,
43
+ ['number', 'number', 'number', 'number', 'number', 'number'],
44
+ ): (number, number, CBoolean, CBoolean, CBoolean, CBoolean) => number,
45
45
  ('hermesParseResult_free', 'void', ['number']): number => void,
46
46
  ('hermesParseResult_getError', 'string', ['number']): number => string,
47
47
  ('hermesParseResult_getErrorLine', 'number', ['number']): number => number,
@@ -18,15 +18,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  *
19
19
  * @format
20
20
  */
21
-
22
- /*
23
- This class does some very "javascripty" things in the name of
24
- performance which are ultimately impossible to soundly type.
25
-
26
- So instead of adding strict types and a large number of suppression
27
- comments, instead it is left untyped and subclasses are strictly
28
- typed via a separate flow declaration file.
29
- */
30
21
  class HermesToBabelAdapter extends _HermesASTAdapter.default {
31
22
  fixSourceLocation(node) {
32
23
  var _this$sourceFilename;
@@ -116,6 +107,12 @@ class HermesToBabelAdapter extends _HermesASTAdapter.default {
116
107
 
117
108
  case 'IndexedAccessType':
118
109
  case 'OptionalIndexedAccessType':
110
+ case 'KeyofTypeAnnotation':
111
+ case 'ConditionalType':
112
+ case 'InferType':
113
+ case 'TupleTypeLabeledElement':
114
+ case 'TupleTypeSpreadElement':
115
+ case 'ObjectTypeMappedTypeProperty':
119
116
  return this.mapUnsupportedTypeAnnotation(node);
120
117
 
121
118
  case 'BigIntLiteral':
@@ -127,6 +124,21 @@ class HermesToBabelAdapter extends _HermesASTAdapter.default {
127
124
  case 'BigIntTypeAnnotation':
128
125
  return this.mapBigIntTypeAnnotation(node);
129
126
 
127
+ case 'TypeofTypeAnnotation':
128
+ return this.mapTypeofTypeAnnotation(node);
129
+
130
+ case 'QualifiedTypeofIdentifier':
131
+ return this.mapQualifiedTypeofIdentifier(node);
132
+
133
+ case 'DeclareVariable':
134
+ return this.mapDeclareVariable(node);
135
+
136
+ case 'DeclareEnum':
137
+ return this.mapDeclareEnum(node);
138
+
139
+ case 'JSXElement':
140
+ return this.mapJSXElement(node);
141
+
130
142
  default:
131
143
  return this.mapNodeDefault(node);
132
144
  }
@@ -518,6 +530,38 @@ class HermesToBabelAdapter extends _HermesASTAdapter.default {
518
530
  return node;
519
531
  }
520
532
 
533
+ mapTypeofTypeAnnotation(nodeUnprocessed) {
534
+ nodeUnprocessed.argument = {
535
+ type: 'GenericTypeAnnotation',
536
+ id: nodeUnprocessed.argument,
537
+ typeParameters: null,
538
+ loc: nodeUnprocessed.argument.loc
539
+ };
540
+ return this.mapNodeDefault(nodeUnprocessed);
541
+ }
542
+
543
+ mapQualifiedTypeofIdentifier(nodeUnprocessed) {
544
+ nodeUnprocessed.type = 'QualifiedTypeIdentifier';
545
+ return this.mapNodeDefault(nodeUnprocessed);
546
+ }
547
+
548
+ mapDeclareVariable(nodeUnprocessed) {
549
+ delete nodeUnprocessed.kind;
550
+ return this.mapNodeDefault(nodeUnprocessed);
551
+ }
552
+
553
+ mapDeclareEnum(nodeUnprocessed) {
554
+ nodeUnprocessed.id.typeAnnotation = this.mapUnsupportedTypeAnnotation(nodeUnprocessed.body);
555
+ delete nodeUnprocessed.body;
556
+ nodeUnprocessed.type = 'DeclareVariable';
557
+ return this.mapDeclareVariable(nodeUnprocessed);
558
+ }
559
+
560
+ mapJSXElement(nodeUnprocessed) {
561
+ delete nodeUnprocessed.openingElement.typeArguments;
562
+ return this.mapNodeDefault(nodeUnprocessed);
563
+ }
564
+
521
565
  }
522
566
 
523
567
  exports.default = HermesToBabelAdapter;
@@ -4,19 +4,10 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow
7
+ * @flow strict
8
8
  * @format
9
9
  */
10
10
 
11
- /*
12
- This class does some very "javascripty" things in the name of
13
- performance which are ultimately impossible to soundly type.
14
-
15
- So instead of adding strict types and a large number of suppression
16
- comments, instead it is left untyped and subclasses are strictly
17
- typed via a separate flow declaration file.
18
- */
19
-
20
11
  import type {HermesNode} from './HermesAST';
21
12
 
22
13
  import HermesASTAdapter from './HermesASTAdapter';
@@ -88,6 +79,12 @@ export default class HermesToBabelAdapter extends HermesASTAdapter {
88
79
  return this.mapFunction(node);
89
80
  case 'IndexedAccessType':
90
81
  case 'OptionalIndexedAccessType':
82
+ case 'KeyofTypeAnnotation':
83
+ case 'ConditionalType':
84
+ case 'InferType':
85
+ case 'TupleTypeLabeledElement':
86
+ case 'TupleTypeSpreadElement':
87
+ case 'ObjectTypeMappedTypeProperty':
91
88
  return this.mapUnsupportedTypeAnnotation(node);
92
89
  case 'BigIntLiteral':
93
90
  return this.mapBigIntLiteral(node);
@@ -95,6 +92,16 @@ export default class HermesToBabelAdapter extends HermesASTAdapter {
95
92
  return this.mapBigIntLiteralTypeAnnotation(node);
96
93
  case 'BigIntTypeAnnotation':
97
94
  return this.mapBigIntTypeAnnotation(node);
95
+ case 'TypeofTypeAnnotation':
96
+ return this.mapTypeofTypeAnnotation(node);
97
+ case 'QualifiedTypeofIdentifier':
98
+ return this.mapQualifiedTypeofIdentifier(node);
99
+ case 'DeclareVariable':
100
+ return this.mapDeclareVariable(node);
101
+ case 'DeclareEnum':
102
+ return this.mapDeclareEnum(node);
103
+ case 'JSXElement':
104
+ return this.mapJSXElement(node);
98
105
  default:
99
106
  return this.mapNodeDefault(node);
100
107
  }
@@ -496,4 +503,44 @@ export default class HermesToBabelAdapter extends HermesASTAdapter {
496
503
 
497
504
  return node;
498
505
  }
506
+
507
+ mapTypeofTypeAnnotation(nodeUnprocessed: HermesNode): HermesNode {
508
+ nodeUnprocessed.argument = {
509
+ type: 'GenericTypeAnnotation',
510
+ id: nodeUnprocessed.argument,
511
+ typeParameters: null,
512
+ loc: nodeUnprocessed.argument.loc,
513
+ };
514
+
515
+ return this.mapNodeDefault(nodeUnprocessed);
516
+ }
517
+
518
+ mapQualifiedTypeofIdentifier(nodeUnprocessed: HermesNode): HermesNode {
519
+ nodeUnprocessed.type = 'QualifiedTypeIdentifier';
520
+
521
+ return this.mapNodeDefault(nodeUnprocessed);
522
+ }
523
+
524
+ mapDeclareVariable(nodeUnprocessed: HermesNode): HermesNode {
525
+ delete nodeUnprocessed.kind;
526
+
527
+ return this.mapNodeDefault(nodeUnprocessed);
528
+ }
529
+
530
+ mapDeclareEnum(nodeUnprocessed: HermesNode): HermesNode {
531
+ nodeUnprocessed.id.typeAnnotation = this.mapUnsupportedTypeAnnotation(
532
+ nodeUnprocessed.body,
533
+ );
534
+
535
+ delete nodeUnprocessed.body;
536
+
537
+ nodeUnprocessed.type = 'DeclareVariable';
538
+
539
+ return this.mapDeclareVariable(nodeUnprocessed);
540
+ }
541
+
542
+ mapJSXElement(nodeUnprocessed: HermesNode): HermesNode {
543
+ delete nodeUnprocessed.openingElement.typeArguments;
544
+ return this.mapNodeDefault(nodeUnprocessed);
545
+ }
499
546
  }
@@ -20,15 +20,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
20
  *
21
21
  * @format
22
22
  */
23
-
24
- /*
25
- This class does some very "javascripty" things in the name of
26
- performance which are ultimately impossible to soundly type.
27
-
28
- So instead of adding strict types and a large number of suppression
29
- comments, instead it is left untyped and subclasses are strictly
30
- typed via a separate flow declaration file.
31
- */
32
23
  class HermesToESTreeAdapter extends _HermesASTAdapter.default {
33
24
  constructor(options, code) {
34
25
  super(options);
@@ -131,10 +122,10 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
131
122
  }
132
123
 
133
124
  mapProgram(node) {
134
- node = this.mapNodeDefault(node);
125
+ const nodeDefault = this.mapNodeDefault(node);
135
126
  node.sourceType = this.getSourceType();
136
- node.docblock = (0, _getModuleDocblock.getModuleDocblock)(node);
137
- return node;
127
+ node.docblock = (0, _getModuleDocblock.getModuleDocblock)(nodeDefault);
128
+ return nodeDefault;
138
129
  }
139
130
 
140
131
  mapSimpleLiteral(node) {
@@ -4,19 +4,10 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow
7
+ * @flow strict
8
8
  * @format
9
9
  */
10
10
 
11
- /*
12
- This class does some very "javascripty" things in the name of
13
- performance which are ultimately impossible to soundly type.
14
-
15
- So instead of adding strict types and a large number of suppression
16
- comments, instead it is left untyped and subclasses are strictly
17
- typed via a separate flow declaration file.
18
- */
19
-
20
11
  import type {HermesNode} from './HermesAST';
21
12
  import type {ParserOptions} from './ParserOptions';
22
13
 
@@ -107,12 +98,12 @@ export default class HermesToESTreeAdapter extends HermesASTAdapter {
107
98
  }
108
99
 
109
100
  mapProgram(node: HermesNode): HermesNode {
110
- node = this.mapNodeDefault(node);
101
+ const nodeDefault = this.mapNodeDefault(node);
111
102
  node.sourceType = this.getSourceType();
112
103
 
113
- node.docblock = getModuleDocblock(node);
104
+ node.docblock = getModuleDocblock(nodeDefault);
114
105
 
115
- return node;
106
+ return nodeDefault;
116
107
  }
117
108
 
118
109
  mapSimpleLiteral(node: HermesNode): HermesNode {
@@ -12,6 +12,7 @@ export type ParserOptions = {
12
12
  allowReturnOutsideFunction?: boolean,
13
13
  babel?: boolean,
14
14
  flow?: 'all' | 'detect',
15
+ enableExperimentalComponentSyntax?: boolean,
15
16
  sourceFilename?: string,
16
17
  sourceType?: 'module' | 'script' | 'unambiguous',
17
18
  tokens?: boolean,
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ * @generated
10
+ */
11
+
12
+ /*
13
+ * !!! GENERATED FILE !!!
14
+ *
15
+ * Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
16
+ */
17
+ // lint directives to let us do some basic validation of generated files
18
+
19
+ /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
+
21
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
22
+ 'use strict';
23
+
24
+ module.exports = {
25
+ AnyTypeAnnotation: [],
26
+ ArrayExpression: ['elements'],
27
+ ArrayPattern: ['elements', 'typeAnnotation'],
28
+ ArrayTypeAnnotation: ['elementType'],
29
+ ArrowFunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
30
+ AssignmentExpression: ['left', 'right'],
31
+ AssignmentPattern: ['left', 'right'],
32
+ AwaitExpression: ['argument'],
33
+ BigIntLiteralTypeAnnotation: [],
34
+ BigIntTypeAnnotation: [],
35
+ BinaryExpression: ['left', 'right'],
36
+ BlockStatement: ['body'],
37
+ BooleanLiteralTypeAnnotation: [],
38
+ BooleanTypeAnnotation: [],
39
+ BreakStatement: ['label'],
40
+ CallExpression: ['callee', 'typeArguments', 'arguments'],
41
+ CatchClause: ['param', 'body'],
42
+ ChainExpression: ['expression'],
43
+ ClassBody: ['body'],
44
+ ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
45
+ ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
46
+ ClassImplements: ['id', 'typeParameters'],
47
+ ComponentDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType'],
48
+ ComponentParameter: ['name', 'local'],
49
+ ComponentTypeAnnotation: ['params', 'rest', 'typeParameters', 'returnType'],
50
+ ComponentTypeParameter: ['name', 'typeAnnotation'],
51
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
52
+ ConditionalTypeAnnotation: ['checkType', 'extendsType', 'trueType', 'falseType'],
53
+ ContinueStatement: ['label'],
54
+ DebuggerStatement: [],
55
+ DeclareClass: ['id', 'typeParameters', 'extends', 'implements', 'mixins', 'body'],
56
+ DeclareComponent: ['id', 'params', 'rest', 'typeParameters', 'returnType'],
57
+ DeclaredPredicate: ['value'],
58
+ DeclareEnum: ['id', 'body'],
59
+ DeclareExportAllDeclaration: ['source'],
60
+ DeclareExportDeclaration: ['declaration', 'specifiers', 'source'],
61
+ DeclareFunction: ['id', 'predicate'],
62
+ DeclareInterface: ['id', 'typeParameters', 'extends', 'body'],
63
+ DeclareModule: ['id', 'body'],
64
+ DeclareModuleExports: ['typeAnnotation'],
65
+ DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
66
+ DeclareTypeAlias: ['id', 'typeParameters', 'right'],
67
+ DeclareVariable: ['id'],
68
+ DoWhileStatement: ['body', 'test'],
69
+ EmptyStatement: [],
70
+ EmptyTypeAnnotation: [],
71
+ EnumBooleanBody: ['members'],
72
+ EnumBooleanMember: ['id', 'init'],
73
+ EnumDeclaration: ['id', 'body'],
74
+ EnumDefaultedMember: ['id'],
75
+ EnumNumberBody: ['members'],
76
+ EnumNumberMember: ['id', 'init'],
77
+ EnumStringBody: ['members'],
78
+ EnumStringMember: ['id', 'init'],
79
+ EnumSymbolBody: ['members'],
80
+ ExistsTypeAnnotation: [],
81
+ ExportAllDeclaration: ['exported', 'source'],
82
+ ExportDefaultDeclaration: ['declaration'],
83
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
84
+ ExportSpecifier: ['exported', 'local'],
85
+ ExpressionStatement: ['expression'],
86
+ ForInStatement: ['left', 'right', 'body'],
87
+ ForOfStatement: ['left', 'right', 'body'],
88
+ ForStatement: ['init', 'test', 'update', 'body'],
89
+ FunctionDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
90
+ FunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
91
+ FunctionTypeAnnotation: ['params', 'this', 'returnType', 'rest', 'typeParameters'],
92
+ FunctionTypeParam: ['name', 'typeAnnotation'],
93
+ GenericTypeAnnotation: ['id', 'typeParameters'],
94
+ Identifier: ['typeAnnotation'],
95
+ IfStatement: ['test', 'consequent', 'alternate'],
96
+ ImportAttribute: ['key', 'value'],
97
+ ImportDeclaration: ['specifiers', 'source', 'assertions'],
98
+ ImportDefaultSpecifier: ['local'],
99
+ ImportExpression: ['source', 'attributes'],
100
+ ImportNamespaceSpecifier: ['local'],
101
+ ImportSpecifier: ['imported', 'local'],
102
+ IndexedAccessType: ['objectType', 'indexType'],
103
+ InferredPredicate: [],
104
+ InferTypeAnnotation: ['typeParameter'],
105
+ InterfaceDeclaration: ['id', 'typeParameters', 'extends', 'body'],
106
+ InterfaceExtends: ['id', 'typeParameters'],
107
+ InterfaceTypeAnnotation: ['extends', 'body'],
108
+ IntersectionTypeAnnotation: ['types'],
109
+ JSXAttribute: ['name', 'value'],
110
+ JSXClosingElement: ['name'],
111
+ JSXClosingFragment: [],
112
+ JSXElement: ['openingElement', 'children', 'closingElement'],
113
+ JSXEmptyExpression: [],
114
+ JSXExpressionContainer: ['expression'],
115
+ JSXFragment: ['openingFragment', 'children', 'closingFragment'],
116
+ JSXIdentifier: [],
117
+ JSXMemberExpression: ['object', 'property'],
118
+ JSXNamespacedName: ['namespace', 'name'],
119
+ JSXOpeningElement: ['name', 'attributes', 'typeArguments'],
120
+ JSXOpeningFragment: [],
121
+ JSXSpreadAttribute: ['argument'],
122
+ JSXSpreadChild: ['expression'],
123
+ JSXText: [],
124
+ KeyofTypeAnnotation: ['argument'],
125
+ LabeledStatement: ['label', 'body'],
126
+ LogicalExpression: ['left', 'right'],
127
+ MemberExpression: ['object', 'property'],
128
+ MetaProperty: ['meta', 'property'],
129
+ MethodDefinition: ['key', 'value'],
130
+ MixedTypeAnnotation: [],
131
+ NewExpression: ['callee', 'typeArguments', 'arguments'],
132
+ NullableTypeAnnotation: ['typeAnnotation'],
133
+ NullLiteralTypeAnnotation: [],
134
+ NumberLiteralTypeAnnotation: [],
135
+ NumberTypeAnnotation: [],
136
+ ObjectExpression: ['properties'],
137
+ ObjectPattern: ['properties', 'typeAnnotation'],
138
+ ObjectTypeAnnotation: ['properties', 'indexers', 'callProperties', 'internalSlots'],
139
+ ObjectTypeCallProperty: ['value'],
140
+ ObjectTypeIndexer: ['id', 'key', 'value', 'variance'],
141
+ ObjectTypeInternalSlot: ['id', 'value'],
142
+ ObjectTypeMappedTypeProperty: ['keyTparam', 'propType', 'sourceType', 'variance'],
143
+ ObjectTypeProperty: ['key', 'value', 'variance'],
144
+ ObjectTypeSpreadProperty: ['argument'],
145
+ OpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
146
+ OptionalIndexedAccessType: ['objectType', 'indexType'],
147
+ PrivateIdentifier: [],
148
+ Program: ['body'],
149
+ Property: ['key', 'value'],
150
+ PropertyDefinition: ['key', 'value', 'variance', 'typeAnnotation', 'tsModifiers'],
151
+ QualifiedTypeIdentifier: ['qualification', 'id'],
152
+ QualifiedTypeofIdentifier: ['qualification', 'id'],
153
+ RestElement: ['argument'],
154
+ ReturnStatement: ['argument'],
155
+ SequenceExpression: ['expressions'],
156
+ SpreadElement: ['argument'],
157
+ StringLiteralTypeAnnotation: [],
158
+ StringTypeAnnotation: [],
159
+ Super: [],
160
+ SwitchCase: ['test', 'consequent'],
161
+ SwitchStatement: ['discriminant', 'cases'],
162
+ SymbolTypeAnnotation: [],
163
+ TaggedTemplateExpression: ['tag', 'quasi'],
164
+ TemplateElement: [],
165
+ TemplateLiteral: ['quasis', 'expressions'],
166
+ ThisExpression: [],
167
+ ThisTypeAnnotation: [],
168
+ ThrowStatement: ['argument'],
169
+ TryStatement: ['block', 'handler', 'finalizer'],
170
+ TupleTypeAnnotation: ['types'],
171
+ TupleTypeLabeledElement: ['label', 'elementType', 'variance'],
172
+ TupleTypeSpreadElement: ['label', 'typeAnnotation'],
173
+ TypeAlias: ['id', 'typeParameters', 'right'],
174
+ TypeAnnotation: ['typeAnnotation'],
175
+ TypeCastExpression: ['expression', 'typeAnnotation'],
176
+ TypeofTypeAnnotation: ['argument'],
177
+ TypeParameter: ['bound', 'variance', 'default'],
178
+ TypeParameterDeclaration: ['params'],
179
+ TypeParameterInstantiation: ['params'],
180
+ TypePredicate: ['parameterName', 'typeAnnotation'],
181
+ UnaryExpression: ['argument'],
182
+ UnionTypeAnnotation: ['types'],
183
+ UpdateExpression: ['argument'],
184
+ VariableDeclaration: ['declarations'],
185
+ VariableDeclarator: ['id', 'init'],
186
+ Variance: [],
187
+ VoidTypeAnnotation: [],
188
+ WhileStatement: ['test', 'body'],
189
+ WithStatement: ['object', 'body'],
190
+ YieldExpression: ['argument'],
191
+ OptionalMemberExpression: ['object', 'property'],
192
+ OptionalCallExpression: ['callee', 'typeArguments', 'arguments'],
193
+ Literal: []
194
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ export type VisitorKeys = $ReadOnly<{[string]: $ReadOnlyArray<string>}>;
14
+
15
+ declare module.exports: VisitorKeys;
@@ -18,7 +18,7 @@
18
18
 
19
19
  /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
20
 
21
- /* global $NonMaybeType, $Partial, $ReadOnly, $ReadOnlyArray */
21
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
22
22
  'use strict';
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
@@ -113,11 +113,38 @@ const HERMES_AST_VISITOR_KEYS = {
113
113
  id: 'Node',
114
114
  typeParameters: 'Node'
115
115
  },
116
+ ComponentDeclaration: {
117
+ id: 'Node',
118
+ params: 'NodeList',
119
+ body: 'Node',
120
+ typeParameters: 'Node',
121
+ returnType: 'Node'
122
+ },
123
+ ComponentParameter: {
124
+ name: 'Node',
125
+ local: 'Node'
126
+ },
127
+ ComponentTypeAnnotation: {
128
+ params: 'NodeList',
129
+ rest: 'Node',
130
+ typeParameters: 'Node',
131
+ returnType: 'Node'
132
+ },
133
+ ComponentTypeParameter: {
134
+ name: 'Node',
135
+ typeAnnotation: 'Node'
136
+ },
116
137
  ConditionalExpression: {
117
138
  test: 'Node',
118
139
  alternate: 'Node',
119
140
  consequent: 'Node'
120
141
  },
142
+ ConditionalTypeAnnotation: {
143
+ checkType: 'Node',
144
+ extendsType: 'Node',
145
+ trueType: 'Node',
146
+ falseType: 'Node'
147
+ },
121
148
  ContinueStatement: {
122
149
  label: 'Node'
123
150
  },
@@ -130,9 +157,20 @@ const HERMES_AST_VISITOR_KEYS = {
130
157
  mixins: 'NodeList',
131
158
  body: 'Node'
132
159
  },
160
+ DeclareComponent: {
161
+ id: 'Node',
162
+ params: 'NodeList',
163
+ rest: 'Node',
164
+ typeParameters: 'Node',
165
+ returnType: 'Node'
166
+ },
133
167
  DeclaredPredicate: {
134
168
  value: 'Node'
135
169
  },
170
+ DeclareEnum: {
171
+ id: 'Node',
172
+ body: 'Node'
173
+ },
136
174
  DeclareExportAllDeclaration: {
137
175
  source: 'Node'
138
176
  },
@@ -312,6 +350,9 @@ const HERMES_AST_VISITOR_KEYS = {
312
350
  indexType: 'Node'
313
351
  },
314
352
  InferredPredicate: {},
353
+ InferTypeAnnotation: {
354
+ typeParameter: 'Node'
355
+ },
315
356
  InterfaceDeclaration: {
316
357
  id: 'Node',
317
358
  typeParameters: 'Node',
@@ -362,7 +403,8 @@ const HERMES_AST_VISITOR_KEYS = {
362
403
  },
363
404
  JSXOpeningElement: {
364
405
  name: 'Node',
365
- attributes: 'NodeList'
406
+ attributes: 'NodeList',
407
+ typeArguments: 'Node'
366
408
  },
367
409
  JSXOpeningFragment: {},
368
410
  JSXSpreadAttribute: {
@@ -372,6 +414,9 @@ const HERMES_AST_VISITOR_KEYS = {
372
414
  expression: 'Node'
373
415
  },
374
416
  JSXText: {},
417
+ KeyofTypeAnnotation: {
418
+ argument: 'Node'
419
+ },
375
420
  LabeledStatement: {
376
421
  label: 'Node',
377
422
  body: 'Node'
@@ -432,6 +477,12 @@ const HERMES_AST_VISITOR_KEYS = {
432
477
  id: 'Node',
433
478
  value: 'Node'
434
479
  },
480
+ ObjectTypeMappedTypeProperty: {
481
+ keyTparam: 'Node',
482
+ propType: 'Node',
483
+ sourceType: 'Node',
484
+ variance: 'Node'
485
+ },
435
486
  ObjectTypeProperty: {
436
487
  key: 'Node',
437
488
  value: 'Node',
@@ -469,6 +520,10 @@ const HERMES_AST_VISITOR_KEYS = {
469
520
  qualification: 'Node',
470
521
  id: 'Node'
471
522
  },
523
+ QualifiedTypeofIdentifier: {
524
+ qualification: 'Node',
525
+ id: 'Node'
526
+ },
472
527
  RegExpLiteral: {},
473
528
  RestElement: {
474
529
  argument: 'Node'
@@ -517,6 +572,15 @@ const HERMES_AST_VISITOR_KEYS = {
517
572
  TupleTypeAnnotation: {
518
573
  types: 'NodeList'
519
574
  },
575
+ TupleTypeLabeledElement: {
576
+ label: 'Node',
577
+ elementType: 'Node',
578
+ variance: 'Node'
579
+ },
580
+ TupleTypeSpreadElement: {
581
+ label: 'Node',
582
+ typeAnnotation: 'Node'
583
+ },
520
584
  TypeAlias: {
521
585
  id: 'Node',
522
586
  typeParameters: 'Node',
@@ -543,6 +607,10 @@ const HERMES_AST_VISITOR_KEYS = {
543
607
  TypeParameterInstantiation: {
544
608
  params: 'NodeList'
545
609
  },
610
+ TypePredicate: {
611
+ parameterName: 'Node',
612
+ typeAnnotation: 'Node'
613
+ },
546
614
  UnaryExpression: {
547
615
  argument: 'Node'
548
616
  },
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  });
15
15
  var _exportNames = {
16
16
  parse: true,
17
+ FlowVisitorKeys: true,
17
18
  astArrayMutationHelpers: true,
18
19
  astNodeMutationHelpers: true
19
20
  };
@@ -26,6 +27,10 @@ var _HermesToBabelAdapter = _interopRequireDefault(require("./HermesToBabelAdapt
26
27
 
27
28
  var _HermesToESTreeAdapter = _interopRequireDefault(require("./HermesToESTreeAdapter"));
28
29
 
30
+ var _ESTreeVisitorKeys = _interopRequireDefault(require("./generated/ESTreeVisitorKeys"));
31
+
32
+ exports.FlowVisitorKeys = _ESTreeVisitorKeys.default;
33
+
29
34
  var _SimpleTraverser = require("./traverse/SimpleTraverser");
30
35
 
31
36
  Object.keys(_SimpleTraverser).forEach(function (key) {
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict-local
7
+ * @flow strict
8
8
  * @format
9
9
  */
10
10
 
@@ -16,6 +16,7 @@ import type {ParserOptions} from './ParserOptions';
16
16
  import * as HermesParser from './HermesParser';
17
17
  import HermesToBabelAdapter from './HermesToBabelAdapter';
18
18
  import HermesToESTreeAdapter from './HermesToESTreeAdapter';
19
+ import FlowVisitorKeys from './generated/ESTreeVisitorKeys';
19
20
 
20
21
  const DEFAULTS = {
21
22
  flow: 'detect',
@@ -86,5 +87,6 @@ export type {ParserOptions} from './ParserOptions';
86
87
  export * from './traverse/SimpleTraverser';
87
88
  export * from './transform/SimpleTransform';
88
89
  export * from './traverse/getVisitorKeys';
90
+ export {FlowVisitorKeys};
89
91
  export * as astArrayMutationHelpers from './transform/astArrayMutationHelpers';
90
92
  export * as astNodeMutationHelpers from './transform/astNodeMutationHelpers';