hermes-parser 0.36.0 → 0.37.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.
Files changed (79) hide show
  1. package/dist/HermesAST.js.flow +2 -2
  2. package/dist/HermesASTAdapter.js +1 -1
  3. package/dist/HermesParser.js +1 -1
  4. package/dist/HermesParserDecodeUTF8String.js +1 -1
  5. package/dist/HermesParserDeserializer.js +1 -1
  6. package/dist/HermesParserDeserializer.js.flow +8 -8
  7. package/dist/HermesParserNodeDeserializers.js +1 -1
  8. package/dist/HermesParserNodeDeserializers.js.flow +1 -1
  9. package/dist/HermesParserWASM.js +1 -1
  10. package/dist/HermesParserWASM.js.flow +6 -6
  11. package/dist/HermesToESTreeAdapter.js +3 -2
  12. package/dist/HermesToESTreeAdapter.js.flow +4 -3
  13. package/dist/ParserOptions.js +5 -3
  14. package/dist/ParserOptions.js.flow +5 -5
  15. package/dist/babel/TransformESTreeToBabel.js +4 -3
  16. package/dist/babel/TransformESTreeToBabel.js.flow +101 -100
  17. package/dist/estree/StripFlowTypes.js +1 -1
  18. package/dist/estree/StripFlowTypesForBabel.js +1 -1
  19. package/dist/estree/TransformComponentSyntax.js +1 -1
  20. package/dist/estree/TransformComponentSyntax.js.flow +3 -3
  21. package/dist/estree/TransformEnumSyntax.js +1 -1
  22. package/dist/estree/TransformEnumSyntax.js.flow +1 -1
  23. package/dist/estree/TransformMatchSyntax.js +11 -2
  24. package/dist/estree/TransformMatchSyntax.js.flow +10 -9
  25. package/dist/estree/TransformRecordSyntax.js +1 -1
  26. package/dist/generated/ESTreeVisitorKeys.js +1 -1
  27. package/dist/generated/ESTreeVisitorKeys.js.flow +1 -1
  28. package/dist/generated/ParserVisitorKeys.js +1 -1
  29. package/dist/generated/ParserVisitorKeys.js.flow +2 -2
  30. package/dist/getModuleDocblock.js +1 -1
  31. package/dist/index.js +4 -3
  32. package/dist/index.js.flow +5 -5
  33. package/dist/src/HermesASTAdapter.js +1 -1
  34. package/dist/src/HermesParser.js +1 -1
  35. package/dist/src/HermesParserDecodeUTF8String.js +1 -1
  36. package/dist/src/HermesParserDeserializer.js +1 -1
  37. package/dist/src/HermesParserNodeDeserializers.js +1 -1
  38. package/dist/src/HermesToESTreeAdapter.js +3 -2
  39. package/dist/src/ParserOptions.js +5 -3
  40. package/dist/src/babel/TransformESTreeToBabel.js +4 -3
  41. package/dist/src/estree/StripFlowTypes.js +1 -1
  42. package/dist/src/estree/StripFlowTypesForBabel.js +1 -1
  43. package/dist/src/estree/TransformComponentSyntax.js +1 -1
  44. package/dist/src/estree/TransformEnumSyntax.js +1 -1
  45. package/dist/src/estree/TransformMatchSyntax.js +11 -2
  46. package/dist/src/estree/TransformRecordSyntax.js +1 -1
  47. package/dist/src/generated/ESTreeVisitorKeys.js +1 -1
  48. package/dist/src/generated/ParserVisitorKeys.js +1 -1
  49. package/dist/src/getModuleDocblock.js +1 -1
  50. package/dist/src/index.js +4 -3
  51. package/dist/src/transform/SimpleTransform.js +10 -1
  52. package/dist/src/transform/astArrayMutationHelpers.js +1 -1
  53. package/dist/src/transform/astNodeMutationHelpers.js +4 -3
  54. package/dist/src/traverse/SimpleTraverser.js +4 -2
  55. package/dist/src/traverse/getVisitorKeys.js +5 -3
  56. package/dist/src/utils/Builders.js +2 -3
  57. package/dist/src/utils/GenID.js +1 -1
  58. package/dist/src/utils/createSyntaxError.js +1 -1
  59. package/dist/src/utils/isReservedWord.js +1 -1
  60. package/dist/src/utils/mutateESTreeASTForPrettier.js +1 -1
  61. package/dist/transform/SimpleTransform.js +10 -1
  62. package/dist/transform/SimpleTransform.js.flow +6 -7
  63. package/dist/transform/astArrayMutationHelpers.js +1 -1
  64. package/dist/transform/astArrayMutationHelpers.js.flow +8 -8
  65. package/dist/transform/astNodeMutationHelpers.js +4 -3
  66. package/dist/transform/astNodeMutationHelpers.js.flow +12 -6
  67. package/dist/traverse/SimpleTraverser.js +4 -2
  68. package/dist/traverse/SimpleTraverser.js.flow +4 -4
  69. package/dist/traverse/getVisitorKeys.js +5 -3
  70. package/dist/traverse/getVisitorKeys.js.flow +5 -3
  71. package/dist/utils/Builders.js +2 -3
  72. package/dist/utils/Builders.js.flow +6 -6
  73. package/dist/utils/GenID.js +1 -1
  74. package/dist/utils/GenID.js.flow +2 -2
  75. package/dist/utils/createSyntaxError.js +1 -1
  76. package/dist/utils/isReservedWord.js +1 -1
  77. package/dist/utils/mutateESTreeASTForPrettier.js +1 -1
  78. package/dist/utils/mutateESTreeASTForPrettier.js.flow +1 -1
  79. package/package.json +4 -3
@@ -12,11 +12,11 @@ type INTENTIONAL_ANY = $FlowFixMe;
12
12
  type JSType = 'number' | 'string' | 'array' | 'boolean';
13
13
  type CBoolean = ?(number | boolean);
14
14
 
15
- type WASMModuleOverrides = $ReadOnly<{
15
+ type WASMModuleOverrides = Readonly<{
16
16
  quit(status: number, toThrow: Error): void,
17
17
  }>;
18
18
 
19
- export type HermesParserWASM = $ReadOnly<{
19
+ export type HermesParserWASM = Readonly<{
20
20
  HEAP8: Int8Array,
21
21
  HEAP16: Int16Array,
22
22
  HEAP32: Int32Array,
@@ -32,11 +32,11 @@ export type HermesParserWASM = $ReadOnly<{
32
32
  ccall(
33
33
  ident: string,
34
34
  returnType: JSType | null,
35
- argTypes: $ReadOnlyArray<JSType>,
36
- args: $ReadOnlyArray<
37
- number | string | $ReadOnlyArray<INTENTIONAL_ANY> | boolean,
35
+ argTypes: ReadonlyArray<JSType>,
36
+ args: ReadonlyArray<
37
+ number | string | ReadonlyArray<INTENTIONAL_ANY> | boolean,
38
38
  >,
39
- opts?: $ReadOnly<{
39
+ opts?: Readonly<{
40
40
  async?: boolean | void,
41
41
  }>,
42
42
  ): INTENTIONAL_ANY,
@@ -17,9 +17,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  *
20
- *
20
+ * strict
21
21
  * @format
22
22
  */
23
+ // eslint-disable-next-line no-unused-vars
23
24
  class HermesToESTreeAdapter extends _HermesASTAdapter.default {
24
25
  constructor(options, code) {
25
26
  super(options);
@@ -185,7 +186,7 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
185
186
 
186
187
  try {
187
188
  value = new RegExp(pattern, flags);
188
- } catch (e) {
189
+ } catch {
189
190
  value = null;
190
191
  }
191
192
 
@@ -14,10 +14,11 @@ import type {ParserOptions} from './ParserOptions';
14
14
  import HermesASTAdapter from './HermesASTAdapter';
15
15
  import {getModuleDocblock} from './getModuleDocblock';
16
16
 
17
- declare var BigInt: ?(value: $FlowFixMe) => mixed;
17
+ // eslint-disable-next-line no-unused-vars
18
+ declare var BigInt: ?(value: $FlowFixMe) => unknown;
18
19
 
19
20
  export default class HermesToESTreeAdapter extends HermesASTAdapter {
20
- +code: string;
21
+ readonly code: string;
21
22
 
22
23
  constructor(options: ParserOptions, code: string) {
23
24
  super(options);
@@ -161,7 +162,7 @@ export default class HermesToESTreeAdapter extends HermesASTAdapter {
161
162
  let value;
162
163
  try {
163
164
  value = new RegExp(pattern, flags);
164
- } catch (e) {
165
+ } catch {
165
166
  value = null;
166
167
  }
167
168
 
@@ -11,8 +11,10 @@ exports.ParserOptionsKeys = void 0;
11
11
  * This source code is licensed under the MIT license found in the
12
12
  * LICENSE file in the root directory of this source tree.
13
13
  *
14
- *
15
- * @format
14
+ * strict
15
+ * @noformat
16
16
  */
17
- const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'enableExperimentalFlowRecordSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
17
+ const ParserOptionsKeys
18
+ /*: ReadonlySet<keyof ParserOptions> */
19
+ = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'enableExperimentalFlowRecordSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
18
20
  exports.ParserOptionsKeys = ParserOptionsKeys;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @flow strict
8
- * @format
8
+ * @noformat
9
9
  */
10
10
 
11
11
  import type {Expression} from 'hermes-estree';
@@ -22,14 +22,14 @@ export type ParserOptions = {
22
22
  sourceType?: 'module' | 'script' | 'unambiguous',
23
23
  tokens?: boolean,
24
24
  transformOptions?: {
25
- +TransformEnumSyntax?: {
26
- +enable: boolean,
27
- +getRuntime?: () => Expression,
25
+ readonly TransformEnumSyntax?: {
26
+ readonly enable: boolean,
27
+ readonly getRuntime?: () => Expression,
28
28
  },
29
29
  },
30
30
  };
31
31
 
32
- export const ParserOptionsKeys: $ReadOnlySet<$Keys<ParserOptions>> = new Set([
32
+ export const ParserOptionsKeys /*: ReadonlySet<keyof ParserOptions> */ = new Set([
33
33
  'allowReturnOutsideFunction',
34
34
  'babel',
35
35
  'flow',
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -277,14 +277,15 @@ function mapProperty(node) {
277
277
 
278
278
  return newNode;
279
279
  } // Non-method property nodes should be renamed to ObjectProperty
280
+ // $FlowExpectedError[incompatible-type]
280
281
 
281
282
 
283
+ const propertyValue = value;
282
284
  return {
283
285
  type: 'ObjectProperty',
284
286
  computed: node.computed,
285
287
  key: node.key,
286
- // $FlowExpectedError[incompatible-type]
287
- value: node.value,
288
+ value: propertyValue,
288
289
  method: node.method,
289
290
  shorthand: node.shorthand,
290
291
  loc: node.loc,
@@ -95,7 +95,7 @@ const FlowESTreeAndBabelVisitorKeys: VisitorKeys = {
95
95
  CommentLine: [],
96
96
  };
97
97
 
98
- function nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
98
+ function nodeWith<T extends ESNode>(node: T, overrideProps: Partial<T>): T {
99
99
  return SimpleTransform.nodeWith(
100
100
  node,
101
101
  overrideProps,
@@ -109,33 +109,33 @@ function nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
109
109
  * Copied from: https://github.com/babel/babel/blob/main/packages/babel-types/src/ast-types/generated/index.ts
110
110
  */
111
111
  export interface BabelFile extends BaseNode {
112
- +type: 'File';
113
- +program: Program;
114
- +comments: $ReadOnlyArray<BabelComment>;
112
+ readonly type: 'File';
113
+ readonly program: Program;
114
+ readonly comments: ReadonlyArray<BabelComment>;
115
115
  }
116
116
 
117
117
  interface BabelCommentBlock extends BaseToken {
118
- +type: 'CommentBlock';
119
- +value: string;
118
+ readonly type: 'CommentBlock';
119
+ readonly value: string;
120
120
  }
121
121
  interface BabelCommentLine extends BaseToken {
122
- +type: 'CommentLine';
123
- +value: string;
122
+ readonly type: 'CommentLine';
123
+ readonly value: string;
124
124
  }
125
125
  type BabelComment = BabelCommentBlock | BabelCommentLine;
126
126
 
127
127
  interface BabelObjectMethod extends BaseNode {
128
- +type: 'ObjectMethod';
129
- +kind: 'method' | 'get' | 'set';
130
- +key: Expression;
131
- +params: $ReadOnlyArray<FunctionParameter>;
132
- +body: BlockStatement;
133
- +computed: boolean;
134
- +generator: boolean;
135
- +async: boolean;
136
- +returnType?: TypeAnnotation | null;
137
- +typeParameters?: TypeParameterDeclaration | null;
138
- +variance?: boolean | null;
128
+ readonly type: 'ObjectMethod';
129
+ readonly kind: 'method' | 'get' | 'set';
130
+ readonly key: Expression;
131
+ readonly params: ReadonlyArray<FunctionParameter>;
132
+ readonly body: BlockStatement;
133
+ readonly computed: boolean;
134
+ readonly generator: boolean;
135
+ readonly async: boolean;
136
+ readonly returnType?: TypeAnnotation | null;
137
+ readonly typeParameters?: TypeParameterDeclaration | null;
138
+ readonly variance?: boolean | null;
139
139
 
140
140
  // TODO: Should these exist?
141
141
  // +id: ...,
@@ -145,146 +145,146 @@ interface BabelObjectMethod extends BaseNode {
145
145
  }
146
146
 
147
147
  interface BabelObjectProperty extends BaseNode {
148
- +type: 'ObjectProperty';
149
- +computed: boolean;
150
- +key: Expression;
151
- +value: Expression;
152
- +method: boolean;
153
- +shorthand: boolean;
148
+ readonly type: 'ObjectProperty';
149
+ readonly computed: boolean;
150
+ readonly key: Expression;
151
+ readonly value: Expression;
152
+ readonly method: boolean;
153
+ readonly shorthand: boolean;
154
154
  }
155
155
 
156
156
  interface BabelClassMethodBase extends BaseNode {
157
- +kind: 'get' | 'set' | 'method' | 'constructor';
158
- +computed: boolean;
159
- +static: boolean;
160
- +key:
157
+ readonly kind: 'get' | 'set' | 'method' | 'constructor';
158
+ readonly computed: boolean;
159
+ readonly static: boolean;
160
+ readonly key:
161
161
  | Identifier
162
162
  | StringLiteral
163
163
  | ClassPropertyNameComputed
164
164
  | ClassPropertyNameNonComputed;
165
- +id: null;
166
- +params: $ReadOnlyArray<FunctionParameter>;
167
- +body: BlockStatement;
168
- +async: boolean;
169
- +generator: boolean;
170
- +returnType?: TypeAnnotation | null;
171
- +typeParameters?: TypeParameterDeclaration | null;
172
- +predicate: null;
165
+ readonly id: null;
166
+ readonly params: ReadonlyArray<FunctionParameter>;
167
+ readonly body: BlockStatement;
168
+ readonly async: boolean;
169
+ readonly generator: boolean;
170
+ readonly returnType?: TypeAnnotation | null;
171
+ readonly typeParameters?: TypeParameterDeclaration | null;
172
+ readonly predicate: null;
173
173
  }
174
174
 
175
175
  interface BabelClassPrivateMethod extends BabelClassMethodBase {
176
- +type: 'ClassPrivateMethod';
176
+ readonly type: 'ClassPrivateMethod';
177
177
  }
178
178
  interface BabelClassMethod extends BabelClassMethodBase {
179
- +type: 'ClassMethod';
179
+ readonly type: 'ClassMethod';
180
180
  }
181
181
 
182
182
  interface BabelClassProperty extends BaseNode {
183
- +type: 'ClassProperty';
184
- +key: Expression;
185
- +value: null | Expression;
186
- +typeAnnotation: null | TypeAnnotation;
187
- +static: boolean;
188
- +variance: null | Variance;
189
- +declare: boolean;
190
- +optional: null | boolean;
191
- +computed: boolean;
183
+ readonly type: 'ClassProperty';
184
+ readonly key: Expression;
185
+ readonly value: null | Expression;
186
+ readonly typeAnnotation: null | TypeAnnotation;
187
+ readonly static: boolean;
188
+ readonly variance: null | Variance;
189
+ readonly declare: boolean;
190
+ readonly optional: null | boolean;
191
+ readonly computed: boolean;
192
192
  }
193
193
 
194
194
  interface BabelClassPrivateProperty extends BaseNode {
195
- +type: 'ClassPrivateProperty';
196
- +key: BabelPrivateName;
197
- +value: null | Expression;
198
- +typeAnnotation: null | TypeAnnotation;
199
- +static: boolean;
200
- +variance: null | Variance;
195
+ readonly type: 'ClassPrivateProperty';
196
+ readonly key: BabelPrivateName;
197
+ readonly value: null | Expression;
198
+ readonly typeAnnotation: null | TypeAnnotation;
199
+ readonly static: boolean;
200
+ readonly variance: null | Variance;
201
201
  }
202
202
 
203
203
  interface BabelExportNamespaceSpecifier extends BaseNode {
204
- +type: 'ExportNamespaceSpecifier';
205
- +exported: Identifier;
204
+ readonly type: 'ExportNamespaceSpecifier';
205
+ readonly exported: Identifier;
206
206
  }
207
207
 
208
208
  interface BabelExportNamedDeclaration extends BaseNode {
209
- +type: 'ExportNamedDeclaration';
210
- +declaration?: null;
211
- +specifiers: $ReadOnlyArray<BabelExportNamespaceSpecifier>;
212
- +source?: StringLiteral | null;
213
- +exportKind: 'value' | 'type';
209
+ readonly type: 'ExportNamedDeclaration';
210
+ readonly declaration?: null;
211
+ readonly specifiers: ReadonlyArray<BabelExportNamespaceSpecifier>;
212
+ readonly source?: StringLiteral | null;
213
+ readonly exportKind: 'value' | 'type';
214
214
  }
215
215
 
216
216
  interface BabelPrivateName extends BaseNode {
217
- +type: 'PrivateName';
218
- +id: Identifier;
217
+ readonly type: 'PrivateName';
218
+ readonly id: Identifier;
219
219
  }
220
220
 
221
221
  interface BabelOptionalMemberExpression extends BaseNode {
222
- +type: 'OptionalMemberExpression';
223
- +object:
222
+ readonly type: 'OptionalMemberExpression';
223
+ readonly object:
224
224
  | Expression
225
225
  | Super
226
226
  | BabelOptionalMemberExpression
227
227
  | BabelOptionalCallExpression;
228
- +property: Expression | Identifier | PrivateIdentifier;
229
- +computed: boolean;
230
- +optional: boolean;
228
+ readonly property: Expression | Identifier | PrivateIdentifier;
229
+ readonly computed: boolean;
230
+ readonly optional: boolean;
231
231
  }
232
232
 
233
233
  interface BabelOptionalCallExpression extends BaseNode {
234
- +type: 'OptionalCallExpression';
235
- +callee:
234
+ readonly type: 'OptionalCallExpression';
235
+ readonly callee:
236
236
  | Expression
237
237
  | Super
238
238
  | BabelOptionalMemberExpression
239
239
  | BabelOptionalCallExpression;
240
- +arguments: $ReadOnlyArray<Expression | SpreadElement>;
241
- +optional: boolean;
242
- +typeArguments?: TypeParameterInstantiation | null;
240
+ readonly arguments: ReadonlyArray<Expression | SpreadElement>;
241
+ readonly optional: boolean;
242
+ readonly typeArguments?: TypeParameterInstantiation | null;
243
243
  }
244
244
 
245
245
  interface BabelStringLiteral extends BaseNode {
246
- +type: 'StringLiteral';
247
- +value: string;
248
- +extra: $ReadOnly<{
249
- +rawValue: string,
250
- +raw: string,
246
+ readonly type: 'StringLiteral';
247
+ readonly value: string;
248
+ readonly extra: Readonly<{
249
+ readonly rawValue: string,
250
+ readonly raw: string,
251
251
  }>;
252
252
  }
253
253
 
254
254
  interface BabelNumericLiteral extends BaseNode {
255
- +type: 'NumericLiteral';
256
- +value: number;
257
- +extra: $ReadOnly<{
258
- +rawValue: number,
259
- +raw: string,
255
+ readonly type: 'NumericLiteral';
256
+ readonly value: number;
257
+ readonly extra: Readonly<{
258
+ readonly rawValue: number,
259
+ readonly raw: string,
260
260
  }>;
261
261
  }
262
262
 
263
263
  interface BabelBigIntLiteral extends BaseNode {
264
- +type: 'BigIntLiteral';
265
- +value: string;
266
- +extra: $ReadOnly<{
267
- +rawValue: string,
268
- +raw: string,
264
+ readonly type: 'BigIntLiteral';
265
+ readonly value: string;
266
+ readonly extra: Readonly<{
267
+ readonly rawValue: string,
268
+ readonly raw: string,
269
269
  }>;
270
270
  }
271
271
 
272
272
  interface BabelBooleanLiteral extends BaseNode {
273
- +type: 'BooleanLiteral';
274
- +value: boolean;
273
+ readonly type: 'BooleanLiteral';
274
+ readonly value: boolean;
275
275
  }
276
276
 
277
277
  interface BabelNullLiteral extends BaseNode {
278
- +type: 'NullLiteral';
278
+ readonly type: 'NullLiteral';
279
279
  }
280
280
 
281
281
  interface BabelRegExpLiteral extends BaseNode {
282
- +type: 'RegExpLiteral';
283
- +extra: $ReadOnly<{
284
- +raw: string,
282
+ readonly type: 'RegExpLiteral';
283
+ readonly extra: Readonly<{
284
+ readonly raw: string,
285
285
  }>;
286
- +pattern: string;
287
- +flags: string;
286
+ readonly pattern: string;
287
+ readonly flags: string;
288
288
  }
289
289
 
290
290
  type BabelLiteral =
@@ -345,7 +345,7 @@ function fixSourceLocation(
345
345
  delete node.parent;
346
346
  }
347
347
 
348
- function mapNodeWithDirectives<T: Program | BlockStatement>(node: T): T {
348
+ function mapNodeWithDirectives<T extends Program | BlockStatement>(node: T): T {
349
349
  // $FlowExpectedError[prop-missing]
350
350
  if (node.directives != null) {
351
351
  return node;
@@ -412,7 +412,7 @@ function mapProgram(node: Program): BabelFile {
412
412
  };
413
413
  const range = [0, endRange];
414
414
 
415
- const babelComments: $ReadOnlyArray<BabelComment> = program.comments.map(
415
+ const babelComments: ReadonlyArray<BabelComment> = program.comments.map(
416
416
  comment => {
417
417
  switch (comment.type) {
418
418
  case 'Line': {
@@ -534,12 +534,13 @@ function mapProperty(node: Property): BabelObjectMethod | BabelObjectProperty {
534
534
  }
535
535
 
536
536
  // Non-method property nodes should be renamed to ObjectProperty
537
+ // $FlowExpectedError[incompatible-type]
538
+ const propertyValue: Expression = value;
537
539
  return {
538
540
  type: 'ObjectProperty',
539
541
  computed: node.computed,
540
542
  key: node.key,
541
- // $FlowExpectedError[incompatible-type]
542
- value: (node.value: Expression),
543
+ value: propertyValue,
543
544
  method: node.method,
544
545
  shorthand: node.shorthand,
545
546
  loc: node.loc,
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
 
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
 
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
 
@@ -174,9 +174,9 @@ function createPropsTypeAnnotation(
174
174
  }
175
175
 
176
176
  function mapComponentParameters(
177
- params: $ReadOnlyArray<ComponentParameter | RestElement>,
177
+ params: ReadonlyArray<ComponentParameter | RestElement>,
178
178
  options: ParserOptions,
179
- ): $ReadOnly<{
179
+ ): Readonly<{
180
180
  props: ?(ObjectPattern | Identifier),
181
181
  ref: ?(BindingName | AssignmentPattern),
182
182
  }> {
@@ -723,7 +723,7 @@ function mapComponentDeclarationIntoList(
723
723
  }
724
724
 
725
725
  function mapStatementList(
726
- stmts: $ReadOnlyArray<Statement | ModuleDeclaration>,
726
+ stmts: ReadonlyArray<Statement | ModuleDeclaration>,
727
727
  options: ParserOptions,
728
728
  ) {
729
729
  const newBody: Array<Statement | ModuleDeclaration> = [];
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -98,7 +98,7 @@ export function transformProgram(
98
98
  options: ParserOptions,
99
99
  ): Program {
100
100
  return SimpleTransform.transformProgram(program, {
101
- transform(node: ESNode): ESNode | $ReadOnlyArray<ESNode> {
101
+ transform(node: ESNode): ESNode | ReadonlyArray<ESNode> {
102
102
  switch (node.type) {
103
103
  case 'EnumDeclaration': {
104
104
  return mapEnumDeclaration(node, options);
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -48,6 +48,14 @@ function genIdent() {
48
48
  * location of to be tested against, or location to be extracted to a binding.
49
49
  */
50
50
 
51
+ /**
52
+ * The conditional aspect of a match pattern for a single location.
53
+ */
54
+
55
+ /**
56
+ * A binding introduced by a match pattern.
57
+ */
58
+
51
59
 
52
60
  function objKeyToString(node) {
53
61
  switch (node.type) {
@@ -368,7 +376,8 @@ function analyzePattern(pattern, key, seenBindingNames) {
368
376
  conditions,
369
377
  bindings
370
378
  } = analyzePattern(asPattern, key, seenBindingNames);
371
- const [id, kind] = target.type === 'MatchBindingPattern' ? [target.id, target.kind] : [target, 'const'];
379
+ const constKind = 'const';
380
+ const [id, kind] = target.type === 'MatchBindingPattern' ? [target.id, target.kind] : [target, constKind];
372
381
  checkDuplicateBindingName(seenBindingNames, pattern, id.name);
373
382
  checkBindingKind(pattern, kind);
374
383
  const binding = {
@@ -351,10 +351,11 @@ function analyzePattern(
351
351
  key,
352
352
  seenBindingNames,
353
353
  );
354
+ const constKind: 'const' = 'const';
354
355
  const [id, kind] =
355
356
  target.type === 'MatchBindingPattern'
356
357
  ? [target.id, target.kind]
357
- : [target, ('const': 'const')];
358
+ : [target, constKind];
358
359
  checkDuplicateBindingName(seenBindingNames, pattern, id.name);
359
360
  checkBindingKind(pattern, kind);
360
361
  const binding: Binding = {type: 'id', key, kind, id};
@@ -725,19 +726,19 @@ function calculateSimpleArgument(node: Expression | Super): boolean {
725
726
  * Analyze the match cases and return information we will use to build the result.
726
727
  */
727
728
  type CaseAnalysis<T> = {
728
- +conditions: Array<Condition>,
729
- +bindings: Array<Binding>,
730
- +guard: Expression | null,
731
- +body: T,
729
+ readonly conditions: Array<Condition>,
730
+ readonly bindings: Array<Binding>,
731
+ readonly guard: Expression | null,
732
+ readonly body: T,
732
733
  };
733
734
 
734
735
  interface MatchCase<T> {
735
- +pattern: MatchPattern;
736
- +guard: Expression | null;
737
- +body: T;
736
+ readonly pattern: MatchPattern;
737
+ readonly guard: Expression | null;
738
+ readonly body: T;
738
739
  }
739
740
 
740
- function analyzeCases<T>(cases: $ReadOnlyArray<MatchCase<T>>): {
741
+ function analyzeCases<T>(cases: ReadonlyArray<MatchCase<T>>): {
741
742
  hasBindings: boolean,
742
743
  hasWildcard: boolean,
743
744
  analyses: Array<CaseAnalysis<T>>,
@@ -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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -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, $FlowFixMe */
21
+ /* global NonNullable, Partial, Readonly, ReadonlyArray, $FlowFixMe */
22
22
  'use strict';
23
23
 
24
24
  module.exports = {
@@ -10,6 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- export type VisitorKeys = $ReadOnly<{[string]: $ReadOnlyArray<string>}>;
13
+ export type VisitorKeys = Readonly<{[string]: ReadonlyArray<string>}>;
14
14
 
15
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, $FlowFixMe */
21
+ /* global NonNullable, Partial, Readonly, ReadonlyArray, $FlowFixMe */
22
22
  'use strict';
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
@@ -10,8 +10,8 @@
10
10
 
11
11
  declare export var NODE_CHILD: 'Node';
12
12
  declare export var NODE_LIST_CHILD: 'NodeList';
13
- declare export var HERMES_AST_VISITOR_KEYS: $ReadOnly<{
14
- [string]: $ReadOnly<{
13
+ declare export var HERMES_AST_VISITOR_KEYS: Readonly<{
14
+ [string]: Readonly<{
15
15
  [string]: 'Node' | 'NodeList',
16
16
  }>,
17
17
  }>;