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
@@ -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';
package/dist/index.js CHANGED
@@ -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';
@@ -135,9 +135,10 @@ function getOptions(options = { ...DEFAULTS
135
135
  options.tokens = options.tokens === true;
136
136
  options.allowReturnOutsideFunction = options.allowReturnOutsideFunction === true;
137
137
  return options;
138
- }
139
-
138
+ } // eslint-disable-next-line no-redeclare
140
139
  // eslint-disable-next-line no-redeclare
140
+
141
+
141
142
  function parse(code, opts) {
142
143
  var _options$transformOpt, _options$transformOpt2;
143
144
 
@@ -25,8 +25,8 @@ import * as StripFlowTypesForBabel from './estree/StripFlowTypesForBabel';
25
25
  import * as TransformESTreeToBabel from './babel/TransformESTreeToBabel';
26
26
  import * as StripFlowTypes from './estree/StripFlowTypes';
27
27
 
28
- const DEFAULTS = {
29
- flow: ('detect': 'detect'),
28
+ const DEFAULTS: {flow: 'detect'} = {
29
+ flow: 'detect',
30
30
  };
31
31
 
32
32
  function getOptions(options?: ParserOptions = {...DEFAULTS}) {
@@ -72,14 +72,14 @@ function getOptions(options?: ParserOptions = {...DEFAULTS}) {
72
72
 
73
73
  declare function parse(
74
74
  code: string,
75
- opts: $ReadOnly<{...ParserOptions, babel: true}>,
75
+ opts: Readonly<{...ParserOptions, babel: true}>,
76
76
  ): BabelFile;
77
77
  // eslint-disable-next-line no-redeclare
78
78
  declare function parse(
79
79
  code: string,
80
80
  opts?:
81
- | $ReadOnly<{...ParserOptions, babel?: false | void}>
82
- | $ReadOnly<{...ParserOptions, babel: false}>,
81
+ | Readonly<{...ParserOptions, babel?: false | void}>
82
+ | Readonly<{...ParserOptions, babel: false}>,
83
83
  ): ESTreeProgram;
84
84
 
85
85
  // eslint-disable-next-line no-redeclare
@@ -13,7 +13,7 @@ var _ParserVisitorKeys = require("./generated/ParserVisitorKeys");
13
13
  * This source code is licensed under the MIT license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  *
16
- *
16
+ * strict
17
17
  * @format
18
18
  */
19
19
 
@@ -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';
@@ -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';
@@ -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
  function deserializeEmpty() {
@@ -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
 
@@ -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;
@@ -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,
@@ -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
 
@@ -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';
@@ -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 = {
@@ -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 = {
@@ -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", {
@@ -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';
package/dist/src/index.js CHANGED
@@ -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';
@@ -135,9 +135,10 @@ function getOptions(options = { ...DEFAULTS
135
135
  options.tokens = options.tokens === true;
136
136
  options.allowReturnOutsideFunction = options.allowReturnOutsideFunction === true;
137
137
  return options;
138
- }
139
-
138
+ } // eslint-disable-next-line no-redeclare
140
139
  // eslint-disable-next-line no-redeclare
140
+
141
+
141
142
  function parse(code, opts) {
142
143
  var _options$transformOpt, _options$transformOpt2;
143
144
 
@@ -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,6 +18,15 @@ var _SimpleTraverser = require("../traverse/SimpleTraverser");
18
18
 
19
19
  var _astNodeMutationHelpers = require("./astNodeMutationHelpers");
20
20
 
21
+ /**
22
+ * Transform callback
23
+ * @param node The node we are visiting
24
+ * @returns
25
+ * - return input node, signals no changes were made will continue to the next node.
26
+ * - return new node, the old node will be replaced in the AST. The new node and its
27
+ * children are then traversed.
28
+ * - return null, signals the node should be deleted from the AST.
29
+ */
21
30
  function setParentPointer(node, parent) {
22
31
  if (parent != null) {
23
32
  if (Array.isArray(node)) {
@@ -14,7 +14,7 @@ exports.replaceInArray = replaceInArray;
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  *
17
- *
17
+ * strict
18
18
  * @format
19
19
  */
20
20
  function assertArrayBounds(array, index) {
@@ -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';
@@ -42,10 +42,11 @@ function getParentKey(target, parent, visitorKeys) {
42
42
  key
43
43
  };
44
44
  }
45
- } else if (Array.isArray(parent[key])) {
45
+ } else if (Array.isArray( // $FlowExpectedError[prop-missing]
46
+ parent[key])) {
46
47
  for (let i = 0; i < parent[key].length; i += 1) {
47
48
  // $FlowExpectedError[invalid-tuple-index]
48
- const current = parent[key][i];
49
+ const current = parent[key][i]; // $FlowFixMe[invalid-compare]
49
50
 
50
51
  if (current === target) {
51
52
  return {
@@ -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';
@@ -80,7 +80,9 @@ class SimpleTraverser {
80
80
  const keys = (0, _getVisitorKeys.getVisitorKeys)(node, options.visitorKeys);
81
81
 
82
82
  for (const key of keys) {
83
- const child = node[key];
83
+ const lookupKey = key;
84
+ const childAny = node[lookupKey];
85
+ const child = childAny;
84
86
 
85
87
  if (Array.isArray(child)) {
86
88
  for (let j = 0; j < child.length; ++j) {
@@ -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
  * @noformat
9
9
  */
10
10
  'use strict';
@@ -20,12 +20,14 @@ var _ESTreeVisitorKeys = _interopRequireDefault(require("../generated/ESTreeVisi
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
22
  function isNode(thing)
23
- /*: implies thing is {+[string]: mixed} */
23
+ /*: implies thing is {readonly [string]: unknown} */
24
24
  {
25
25
  return typeof thing === 'object' && thing != null && typeof thing.type === 'string';
26
26
  }
27
27
 
28
- function getVisitorKeys(node, visitorKeys) {
28
+ function getVisitorKeys(node, visitorKeys)
29
+ /*: ReadonlyArray<keyof T> */
30
+ {
29
31
  const keys = (visitorKeys != null ? visitorKeys : _ESTreeVisitorKeys.default)[node.type];
30
32
 
31
33
  if (keys == null) {
@@ -4,10 +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
- *
7
+ * strict
8
8
  * @format
9
9
  */
10
- 'use strict';
10
+ 'use strict'; // Rely on the mapper to fix up parent relationships.
11
11
 
12
12
  Object.defineProperty(exports, "__esModule", {
13
13
  value: true
@@ -26,7 +26,6 @@ exports.stringLiteral = stringLiteral;
26
26
  exports.throwStatement = throwStatement;
27
27
  exports.typeofExpression = typeofExpression;
28
28
  exports.variableDeclaration = variableDeclaration;
29
- // Rely on the mapper to fix up parent relationships.
30
29
  const EMPTY_PARENT = null;
31
30
  exports.EMPTY_PARENT = EMPTY_PARENT;
32
31
 
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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,6 +18,15 @@ var _SimpleTraverser = require("../traverse/SimpleTraverser");
18
18
 
19
19
  var _astNodeMutationHelpers = require("./astNodeMutationHelpers");
20
20
 
21
+ /**
22
+ * Transform callback
23
+ * @param node The node we are visiting
24
+ * @returns
25
+ * - return input node, signals no changes were made will continue to the next node.
26
+ * - return new node, the old node will be replaced in the AST. The new node and its
27
+ * children are then traversed.
28
+ * - return null, signals the node should be deleted from the AST.
29
+ */
21
30
  function setParentPointer(node, parent) {
22
31
  if (parent != null) {
23
32
  if (Array.isArray(node)) {
@@ -31,9 +31,9 @@ import {
31
31
  */
32
32
  export type TransformCallback = (
33
33
  node: ESNode,
34
- ) => ESNode | $ReadOnlyArray<ESNode> | null;
34
+ ) => ESNode | ReadonlyArray<ESNode> | null;
35
35
 
36
- export type TransformOptions = $ReadOnly<{
36
+ export type TransformOptions = Readonly<{
37
37
  /** The callback function which is called on entering each node. */
38
38
  transform: TransformCallback,
39
39
 
@@ -42,7 +42,7 @@ export type TransformOptions = $ReadOnly<{
42
42
  }>;
43
43
 
44
44
  function setParentPointer(
45
- node: ESNode | $ReadOnlyArray<ESNode>,
45
+ node: ESNode | ReadonlyArray<ESNode>,
46
46
  parent: ?ESNode,
47
47
  ): void {
48
48
  if (parent != null) {
@@ -75,11 +75,10 @@ export class SimpleTransform {
75
75
  // Ensure the parent pointers are correctly set before entering the node.
76
76
  setParentPointer(node, parent);
77
77
 
78
- const resultNode: ESNode | $ReadOnlyArray<ESNode> | null =
78
+ const resultNode: ESNode | ReadonlyArray<ESNode> | null =
79
79
  options.transform(node);
80
80
  if (resultNode !== node) {
81
- let traversedResultNode: ESNode | $ReadOnlyArray<ESNode> | null =
82
- null;
81
+ let traversedResultNode: ESNode | ReadonlyArray<ESNode> | null = null;
83
82
 
84
83
  if (resultNode != null) {
85
84
  // Ensure the new node has the correct parent pointers before recursing again.
@@ -159,7 +158,7 @@ export class SimpleTransform {
159
158
  * @return Either the orginal node if the properties matched the existing node or a new node with
160
159
  * the new properties.
161
160
  */
162
- static nodeWith<T: ESNode>(
161
+ static nodeWith<T extends ESNode>(
163
162
  node: T,
164
163
  overrideProps: Partial<T>,
165
164
  visitorKeys?: VisitorKeysType,
@@ -14,7 +14,7 @@ exports.replaceInArray = replaceInArray;
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  *
17
- *
17
+ * strict
18
18
  * @format
19
19
  */
20
20
  function assertArrayBounds(array, index) {
@@ -8,7 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
- function assertArrayBounds<T>(array: $ReadOnlyArray<T>, index: number): void {
11
+ function assertArrayBounds<T>(array: ReadonlyArray<T>, index: number): void {
12
12
  if (index < 0 || index >= array.length) {
13
13
  throw new Error(
14
14
  `Invalid Mutation: Tried to mutate an elements array with an out of bounds index. Index: ${index}, Array Size: ${array.length}`,
@@ -17,8 +17,8 @@ function assertArrayBounds<T>(array: $ReadOnlyArray<T>, index: number): void {
17
17
  }
18
18
 
19
19
  export function arrayIsEqual(
20
- a1: $ReadOnlyArray<mixed>,
21
- a2: $ReadOnlyArray<mixed>,
20
+ a1: ReadonlyArray<unknown>,
21
+ a2: ReadonlyArray<unknown>,
22
22
  ): boolean {
23
23
  if (a1 === a2) {
24
24
  return true;
@@ -38,9 +38,9 @@ export function arrayIsEqual(
38
38
  }
39
39
 
40
40
  export function insertInArray<T>(
41
- array: $ReadOnlyArray<T>,
41
+ array: ReadonlyArray<T>,
42
42
  index: number,
43
- elements: $ReadOnlyArray<T>,
43
+ elements: ReadonlyArray<T>,
44
44
  ): Array<T> {
45
45
  if (index === array.length) {
46
46
  // Support the insert at end of array case.
@@ -51,7 +51,7 @@ export function insertInArray<T>(
51
51
  }
52
52
 
53
53
  export function removeFromArray<T>(
54
- array: $ReadOnlyArray<T>,
54
+ array: ReadonlyArray<T>,
55
55
  index: number,
56
56
  ): Array<T> {
57
57
  assertArrayBounds(array, index);
@@ -59,9 +59,9 @@ export function removeFromArray<T>(
59
59
  }
60
60
 
61
61
  export function replaceInArray<T>(
62
- array: $ReadOnlyArray<T>,
62
+ array: ReadonlyArray<T>,
63
63
  index: number,
64
- elements: $ReadOnlyArray<T>,
64
+ elements: ReadonlyArray<T>,
65
65
  ): Array<T> {
66
66
  assertArrayBounds(array, index);
67
67
  return array
@@ -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';
@@ -42,10 +42,11 @@ function getParentKey(target, parent, visitorKeys) {
42
42
  key
43
43
  };
44
44
  }
45
- } else if (Array.isArray(parent[key])) {
45
+ } else if (Array.isArray( // $FlowExpectedError[prop-missing]
46
+ parent[key])) {
46
47
  for (let i = 0; i < parent[key].length; i += 1) {
47
48
  // $FlowExpectedError[invalid-tuple-index]
48
- const current = parent[key][i];
49
+ const current = parent[key][i]; // $FlowFixMe[invalid-compare]
49
50
 
50
51
  if (current === target) {
51
52
  return {