hermes-transform 0.32.0 → 0.33.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.
@@ -133,6 +133,8 @@ var _exportNames = {
133
133
  MatchExpression: true,
134
134
  MatchExpressionCase: true,
135
135
  MatchIdentifierPattern: true,
136
+ MatchInstanceObjectPattern: true,
137
+ MatchInstancePattern: true,
136
138
  MatchLiteralPattern: true,
137
139
  MatchMemberPattern: true,
138
140
  MatchObjectPattern: true,
@@ -146,6 +148,7 @@ var _exportNames = {
146
148
  MetaProperty: true,
147
149
  MethodDefinition: true,
148
150
  MixedTypeAnnotation: true,
151
+ NeverTypeAnnotation: true,
149
152
  NewExpression: true,
150
153
  NullableTypeAnnotation: true,
151
154
  NullLiteralTypeAnnotation: true,
@@ -166,6 +169,13 @@ var _exportNames = {
166
169
  PropertyDefinition: true,
167
170
  QualifiedTypeIdentifier: true,
168
171
  QualifiedTypeofIdentifier: true,
172
+ RecordDeclaration: true,
173
+ RecordDeclarationBody: true,
174
+ RecordDeclarationImplements: true,
175
+ RecordDeclarationProperty: true,
176
+ RecordDeclarationStaticProperty: true,
177
+ RecordExpression: true,
178
+ RecordExpressionProperties: true,
169
179
  RestElement: true,
170
180
  ReturnStatement: true,
171
181
  SequenceExpression: true,
@@ -196,7 +206,9 @@ var _exportNames = {
196
206
  TypeParameterInstantiation: true,
197
207
  TypePredicate: true,
198
208
  UnaryExpression: true,
209
+ UndefinedTypeAnnotation: true,
199
210
  UnionTypeAnnotation: true,
211
+ UnknownTypeAnnotation: true,
200
212
  UpdateExpression: true,
201
213
  VariableDeclaration: true,
202
214
  VariableDeclarator: true,
@@ -314,6 +326,8 @@ exports.MatchBindingPattern = MatchBindingPattern;
314
326
  exports.MatchExpression = MatchExpression;
315
327
  exports.MatchExpressionCase = MatchExpressionCase;
316
328
  exports.MatchIdentifierPattern = MatchIdentifierPattern;
329
+ exports.MatchInstanceObjectPattern = MatchInstanceObjectPattern;
330
+ exports.MatchInstancePattern = MatchInstancePattern;
317
331
  exports.MatchLiteralPattern = MatchLiteralPattern;
318
332
  exports.MatchMemberPattern = MatchMemberPattern;
319
333
  exports.MatchObjectPattern = MatchObjectPattern;
@@ -327,6 +341,7 @@ exports.MatchWildcardPattern = MatchWildcardPattern;
327
341
  exports.MetaProperty = MetaProperty;
328
342
  exports.MethodDefinition = MethodDefinition;
329
343
  exports.MixedTypeAnnotation = MixedTypeAnnotation;
344
+ exports.NeverTypeAnnotation = NeverTypeAnnotation;
330
345
  exports.NewExpression = NewExpression;
331
346
  exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
332
347
  exports.NullableTypeAnnotation = NullableTypeAnnotation;
@@ -347,6 +362,13 @@ exports.Property = Property;
347
362
  exports.PropertyDefinition = PropertyDefinition;
348
363
  exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
349
364
  exports.QualifiedTypeofIdentifier = QualifiedTypeofIdentifier;
365
+ exports.RecordDeclaration = RecordDeclaration;
366
+ exports.RecordDeclarationBody = RecordDeclarationBody;
367
+ exports.RecordDeclarationImplements = RecordDeclarationImplements;
368
+ exports.RecordDeclarationProperty = RecordDeclarationProperty;
369
+ exports.RecordDeclarationStaticProperty = RecordDeclarationStaticProperty;
370
+ exports.RecordExpression = RecordExpression;
371
+ exports.RecordExpressionProperties = RecordExpressionProperties;
350
372
  exports.RestElement = RestElement;
351
373
  exports.ReturnStatement = ReturnStatement;
352
374
  exports.SequenceExpression = SequenceExpression;
@@ -377,7 +399,9 @@ exports.TypeParameterInstantiation = TypeParameterInstantiation;
377
399
  exports.TypePredicate = TypePredicate;
378
400
  exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
379
401
  exports.UnaryExpression = UnaryExpression;
402
+ exports.UndefinedTypeAnnotation = UndefinedTypeAnnotation;
380
403
  exports.UnionTypeAnnotation = UnionTypeAnnotation;
404
+ exports.UnknownTypeAnnotation = UnknownTypeAnnotation;
381
405
  exports.UpdateExpression = UpdateExpression;
382
406
  exports.VariableDeclaration = VariableDeclaration;
383
407
  exports.VariableDeclarator = VariableDeclarator;
@@ -581,7 +605,7 @@ function ClassExpression(props) {
581
605
  id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
582
606
  typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
583
607
  superClass: (0, _detachedNode.asDetachedNodeForCodeGen)(props.superClass),
584
- superTypeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.superTypeParameters),
608
+ superTypeArguments: (0, _detachedNode.asDetachedNodeForCodeGen)(props.superTypeArguments),
585
609
  implements: props.implements.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
586
610
  decorators: props.decorators.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
587
611
  body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body)
@@ -1498,6 +1522,26 @@ function MatchIdentifierPattern(props) {
1498
1522
  return node;
1499
1523
  }
1500
1524
 
1525
+ function MatchInstanceObjectPattern(props) {
1526
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1527
+ type: 'MatchInstanceObjectPattern',
1528
+ properties: props.properties.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1529
+ rest: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rest)
1530
+ });
1531
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1532
+ return node;
1533
+ }
1534
+
1535
+ function MatchInstancePattern(props) {
1536
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1537
+ type: 'MatchInstancePattern',
1538
+ targetConstructor: (0, _detachedNode.asDetachedNodeForCodeGen)(props.targetConstructor),
1539
+ properties: (0, _detachedNode.asDetachedNodeForCodeGen)(props.properties)
1540
+ });
1541
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1542
+ return node;
1543
+ }
1544
+
1501
1545
  function MatchLiteralPattern(props) {
1502
1546
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1503
1547
  type: 'MatchLiteralPattern',
@@ -1624,6 +1668,13 @@ function MixedTypeAnnotation(props = { ...null
1624
1668
  });
1625
1669
  }
1626
1670
 
1671
+ function NeverTypeAnnotation(props = { ...null
1672
+ }) {
1673
+ return (0, _detachedNode.detachedProps)(props.parent, {
1674
+ type: 'NeverTypeAnnotation'
1675
+ });
1676
+ }
1677
+
1627
1678
  function NewExpression(props) {
1628
1679
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1629
1680
  type: 'NewExpression',
@@ -1843,6 +1894,79 @@ function QualifiedTypeofIdentifier(props) {
1843
1894
  return node;
1844
1895
  }
1845
1896
 
1897
+ function RecordDeclaration(props) {
1898
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1899
+ type: 'RecordDeclaration',
1900
+ id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
1901
+ typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
1902
+ implements: props.implements.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1903
+ body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body)
1904
+ });
1905
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1906
+ return node;
1907
+ }
1908
+
1909
+ function RecordDeclarationBody(props) {
1910
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1911
+ type: 'RecordDeclarationBody',
1912
+ elements: props.elements.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n))
1913
+ });
1914
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1915
+ return node;
1916
+ }
1917
+
1918
+ function RecordDeclarationImplements(props) {
1919
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1920
+ type: 'RecordDeclarationImplements',
1921
+ id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
1922
+ typeArguments: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeArguments)
1923
+ });
1924
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1925
+ return node;
1926
+ }
1927
+
1928
+ function RecordDeclarationProperty(props) {
1929
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1930
+ type: 'RecordDeclarationProperty',
1931
+ key: (0, _detachedNode.asDetachedNodeForCodeGen)(props.key),
1932
+ typeAnnotation: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeAnnotation),
1933
+ defaultValue: (0, _detachedNode.asDetachedNodeForCodeGen)(props.defaultValue)
1934
+ });
1935
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1936
+ return node;
1937
+ }
1938
+
1939
+ function RecordDeclarationStaticProperty(props) {
1940
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1941
+ type: 'RecordDeclarationStaticProperty',
1942
+ key: (0, _detachedNode.asDetachedNodeForCodeGen)(props.key),
1943
+ typeAnnotation: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeAnnotation),
1944
+ value: (0, _detachedNode.asDetachedNodeForCodeGen)(props.value)
1945
+ });
1946
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1947
+ return node;
1948
+ }
1949
+
1950
+ function RecordExpression(props) {
1951
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1952
+ type: 'RecordExpression',
1953
+ recordConstructor: (0, _detachedNode.asDetachedNodeForCodeGen)(props.recordConstructor),
1954
+ typeArguments: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeArguments),
1955
+ properties: (0, _detachedNode.asDetachedNodeForCodeGen)(props.properties)
1956
+ });
1957
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1958
+ return node;
1959
+ }
1960
+
1961
+ function RecordExpressionProperties(props) {
1962
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
1963
+ type: 'RecordExpressionProperties',
1964
+ properties: props.properties.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n))
1965
+ });
1966
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
1967
+ return node;
1968
+ }
1969
+
1846
1970
  function RestElement(props) {
1847
1971
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1848
1972
  type: 'RestElement',
@@ -1996,7 +2120,7 @@ function TryStatement(props) {
1996
2120
  function TupleTypeAnnotation(props) {
1997
2121
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1998
2122
  type: 'TupleTypeAnnotation',
1999
- types: props.types.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
2123
+ elementTypes: props.elementTypes.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
2000
2124
  inexact: props.inexact
2001
2125
  });
2002
2126
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -2129,6 +2253,13 @@ function UnaryExpression(props) {
2129
2253
  return node;
2130
2254
  }
2131
2255
 
2256
+ function UndefinedTypeAnnotation(props = { ...null
2257
+ }) {
2258
+ return (0, _detachedNode.detachedProps)(props.parent, {
2259
+ type: 'UndefinedTypeAnnotation'
2260
+ });
2261
+ }
2262
+
2132
2263
  function UnionTypeAnnotation(props) {
2133
2264
  const node = (0, _detachedNode.detachedProps)(props.parent, {
2134
2265
  type: 'UnionTypeAnnotation',
@@ -2138,6 +2269,13 @@ function UnionTypeAnnotation(props) {
2138
2269
  return node;
2139
2270
  }
2140
2271
 
2272
+ function UnknownTypeAnnotation(props = { ...null
2273
+ }) {
2274
+ return (0, _detachedNode.detachedProps)(props.parent, {
2275
+ type: 'UnknownTypeAnnotation'
2276
+ });
2277
+ }
2278
+
2141
2279
  function UpdateExpression(props) {
2142
2280
  const node = (0, _detachedNode.detachedProps)(props.parent, {
2143
2281
  type: 'UpdateExpression',
@@ -55,7 +55,7 @@ function ClassDeclaration(props) {
55
55
  // $FlowFixMe[incompatible-type]
56
56
  superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
57
57
  // $FlowFixMe[incompatible-type]
58
- superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
58
+ superTypeArguments: (0, _detachedNode.asDetachedNode)(props.superTypeArguments),
59
59
  decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
60
60
  implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
61
61
  body: (0, _detachedNode.asDetachedNode)(props.body)
@@ -128,14 +128,17 @@ function cloneJSDocCommentsToNewNode(oldNode, newNode) {
128
128
  }
129
129
 
130
130
  function setCommentsOnNode(node, comments) {
131
- // $FlowExpectedError - this property is secretly added by prettier.
131
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
132
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
133
+ // $FlowExpectedError[cannot-write] - this property is secretly added by prettier.
132
134
  node.comments = comments;
133
135
  }
134
136
 
135
137
  function getCommentsForNode(node) {
136
138
  var _node$comments;
137
139
 
138
- // $FlowExpectedError - this property is secretly added by prettier.
140
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
141
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
139
142
  return (_node$comments = node.comments) != null ? _node$comments : [];
140
143
  }
141
144
 
@@ -146,12 +149,12 @@ function isAttachedComment(comment) {
146
149
  }
147
150
 
148
151
  function isLeadingComment(comment) {
149
- // $FlowExpectedError - this property is secretly added by prettier.
152
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
150
153
  return comment.leading === true;
151
154
  }
152
155
 
153
156
  function isTrailingComment(comment) {
154
- // $FlowExpectedError - this property is secretly added by prettier.
157
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
155
158
  return comment.trailing === true;
156
159
  }
157
160
 
@@ -33,6 +33,7 @@ function performModifyNodeInPlaceMutation(mutationContext, mutation) {
33
33
 
34
34
  for (const [key, newPropValue] of Object.entries(newProps)) {
35
35
  const prevPropValue = target[key]; // If the value did not change, skip.
36
+ // $FlowFixMe[invalid-compare]
36
37
 
37
38
  if (prevPropValue === newPropValue) {
38
39
  continue;
@@ -140,6 +140,7 @@ function getRemovalParent(node) {
140
140
  case 'ObjectPattern':
141
141
  return 'properties';
142
142
  // $FlowFixMe[incompatible-type]
143
+ // $FlowFixMe[invalid-compare]
143
144
 
144
145
  case 'OptionalCallExpression':
145
146
  case 'CallExpression':
@@ -160,6 +161,7 @@ function getRemovalParent(node) {
160
161
  case 'ObjectExpression':
161
162
  return 'properties';
162
163
  // $FlowFixMe[incompatible-type]
164
+ // $FlowFixMe[invalid-compare]
163
165
 
164
166
  case 'OptionalCallExpression':
165
167
  case 'CallExpression':
@@ -178,7 +180,7 @@ function getRemovalParent(node) {
178
180
  const targetIndex = (() => {
179
181
  // $FlowExpectedError[prop-missing]
180
182
  const arr = node.parent[key];
181
- const idx = arr.indexOf(node);
183
+ const idx = arr.indexOf(node); // $FlowFixMe[invalid-compare]
182
184
 
183
185
  if (idx === -1) {
184
186
  throw new _Errors.InvalidRemovalError(`Could not find target in array of \`${node.parent.type}.${key}\`.`);
@@ -63,6 +63,7 @@ function getParentKey(target) {
63
63
  const child = parent[key];
64
64
 
65
65
  if ((0, _hermesParser.isNode)(child)) {
66
+ // $FlowFixMe[invalid-compare]
66
67
  if (child === target) {
67
68
  return {
68
69
  type: 'single',
@@ -22,7 +22,8 @@ function getStatementParent(target) {
22
22
  // $FlowExpectedError[prop-missing]
23
23
  const value = parentWithType[key];
24
24
 
25
- if (value === target || Array.isArray(value) && value.includes(target)) {
25
+ if ( // $FlowFixMe[invalid-compare]
26
+ value === target || Array.isArray(value) && value.includes(target)) {
26
27
  throw new _Errors.InvalidStatementError(`Attempted to insert a statement into \`${parentWithType.type}.${key}\`.`);
27
28
  }
28
29
  }
@@ -135,6 +136,7 @@ function getStatementParent(target) {
135
136
 
136
137
  if ( // array insertions are already validated by the getAssertedIndex function
137
138
  result.targetIndex == null && // $FlowExpectedError[prop-missing]
139
+ // $FlowFixMe[invalid-compare]
138
140
  result.parent[result.key] !== target) {
139
141
  throw new _Errors.InvalidStatementError(`Expected to find the target "${target.type}" on the "${result.parent.type}.${result.key}", but found a different node. ` + 'This likely means that you attempted to mutate around the target after it was deleted/replaced.');
140
142
  }
@@ -128,14 +128,17 @@ function cloneJSDocCommentsToNewNode(oldNode, newNode) {
128
128
  }
129
129
 
130
130
  function setCommentsOnNode(node, comments) {
131
- // $FlowExpectedError - this property is secretly added by prettier.
131
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
132
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
133
+ // $FlowExpectedError[cannot-write] - this property is secretly added by prettier.
132
134
  node.comments = comments;
133
135
  }
134
136
 
135
137
  function getCommentsForNode(node) {
136
138
  var _node$comments;
137
139
 
138
- // $FlowExpectedError - this property is secretly added by prettier.
140
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
141
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
139
142
  return (_node$comments = node.comments) != null ? _node$comments : [];
140
143
  }
141
144
 
@@ -146,12 +149,12 @@ function isAttachedComment(comment) {
146
149
  }
147
150
 
148
151
  function isLeadingComment(comment) {
149
- // $FlowExpectedError - this property is secretly added by prettier.
152
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
150
153
  return comment.leading === true;
151
154
  }
152
155
 
153
156
  function isTrailingComment(comment) {
154
- // $FlowExpectedError - this property is secretly added by prettier.
157
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
155
158
  return comment.trailing === true;
156
159
  }
157
160
 
@@ -147,14 +147,17 @@ export function setCommentsOnNode(
147
147
  node: ESNode | DetachedNode<ESNode>,
148
148
  comments: $ReadOnlyArray<Comment>,
149
149
  ): void {
150
- // $FlowExpectedError - this property is secretly added by prettier.
150
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
151
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
152
+ // $FlowExpectedError[cannot-write] - this property is secretly added by prettier.
151
153
  node.comments = comments;
152
154
  }
153
155
 
154
156
  export function getCommentsForNode(
155
157
  node: ESNode | DetachedNode<ESNode>,
156
158
  ): $ReadOnlyArray<Comment> {
157
- // $FlowExpectedError - this property is secretly added by prettier.
159
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
160
+ // $FlowExpectedError[incompatible-use] - this property is secretly added by prettier.
158
161
  return node.comments ?? [];
159
162
  }
160
163
 
@@ -165,11 +168,11 @@ export function isAttachedComment(comment: Comment): boolean {
165
168
  }
166
169
 
167
170
  export function isLeadingComment(comment: Comment): boolean {
168
- // $FlowExpectedError - this property is secretly added by prettier.
171
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
169
172
  return comment.leading === true;
170
173
  }
171
174
  export function isTrailingComment(comment: Comment): boolean {
172
- // $FlowExpectedError - this property is secretly added by prettier.
175
+ // $FlowExpectedError[prop-missing] - this property is secretly added by prettier.
173
176
  return comment.trailing === true;
174
177
  }
175
178
 
@@ -33,6 +33,7 @@ function performModifyNodeInPlaceMutation(mutationContext, mutation) {
33
33
 
34
34
  for (const [key, newPropValue] of Object.entries(newProps)) {
35
35
  const prevPropValue = target[key]; // If the value did not change, skip.
36
+ // $FlowFixMe[invalid-compare]
36
37
 
37
38
  if (prevPropValue === newPropValue) {
38
39
  continue;
@@ -40,6 +40,7 @@ export function performModifyNodeInPlaceMutation(
40
40
  const prevPropValue = target[key];
41
41
 
42
42
  // If the value did not change, skip.
43
+ // $FlowFixMe[invalid-compare]
43
44
  if (prevPropValue === newPropValue) {
44
45
  continue;
45
46
  }
@@ -140,6 +140,7 @@ function getRemovalParent(node) {
140
140
  case 'ObjectPattern':
141
141
  return 'properties';
142
142
  // $FlowFixMe[incompatible-type]
143
+ // $FlowFixMe[invalid-compare]
143
144
 
144
145
  case 'OptionalCallExpression':
145
146
  case 'CallExpression':
@@ -160,6 +161,7 @@ function getRemovalParent(node) {
160
161
  case 'ObjectExpression':
161
162
  return 'properties';
162
163
  // $FlowFixMe[incompatible-type]
164
+ // $FlowFixMe[invalid-compare]
163
165
 
164
166
  case 'OptionalCallExpression':
165
167
  case 'CallExpression':
@@ -178,7 +180,7 @@ function getRemovalParent(node) {
178
180
  const targetIndex = (() => {
179
181
  // $FlowExpectedError[prop-missing]
180
182
  const arr = node.parent[key];
181
- const idx = arr.indexOf(node);
183
+ const idx = arr.indexOf(node); // $FlowFixMe[invalid-compare]
182
184
 
183
185
  if (idx === -1) {
184
186
  throw new _Errors.InvalidRemovalError(`Could not find target in array of \`${node.parent.type}.${key}\`.`);
@@ -216,6 +216,7 @@ function getRemovalParent(node: RemoveNodeMutation['node']): $ReadOnly<{
216
216
  return 'properties';
217
217
 
218
218
  // $FlowFixMe[incompatible-type]
219
+ // $FlowFixMe[invalid-compare]
219
220
  case 'OptionalCallExpression':
220
221
  case 'CallExpression':
221
222
  case 'NewExpression':
@@ -247,6 +248,7 @@ function getRemovalParent(node: RemoveNodeMutation['node']): $ReadOnly<{
247
248
  return 'properties';
248
249
 
249
250
  // $FlowFixMe[incompatible-type]
251
+ // $FlowFixMe[invalid-compare]
250
252
  case 'OptionalCallExpression':
251
253
  case 'CallExpression':
252
254
  case 'NewExpression':
@@ -275,6 +277,7 @@ function getRemovalParent(node: RemoveNodeMutation['node']): $ReadOnly<{
275
277
  // $FlowExpectedError[prop-missing]
276
278
  const arr = node.parent[key];
277
279
  const idx = arr.indexOf(node);
280
+ // $FlowFixMe[invalid-compare]
278
281
  if (idx === -1) {
279
282
  throw new InvalidRemovalError(
280
283
  `Could not find target in array of \`${node.parent.type}.${key}\`.`,
@@ -63,6 +63,7 @@ function getParentKey(target) {
63
63
  const child = parent[key];
64
64
 
65
65
  if ((0, _hermesParser.isNode)(child)) {
66
+ // $FlowFixMe[invalid-compare]
66
67
  if (child === target) {
67
68
  return {
68
69
  type: 'single',
@@ -90,6 +90,7 @@ function getParentKey(target: ESNode): $ReadOnly<
90
90
  for (const key of getVisitorKeys(parent)) {
91
91
  const child = (parent: $FlowFixMe)[key];
92
92
  if (isNode(child)) {
93
+ // $FlowFixMe[invalid-compare]
93
94
  if (child === target) {
94
95
  return {type: 'single', parent, key};
95
96
  }
@@ -22,7 +22,8 @@ function getStatementParent(target) {
22
22
  // $FlowExpectedError[prop-missing]
23
23
  const value = parentWithType[key];
24
24
 
25
- if (value === target || Array.isArray(value) && value.includes(target)) {
25
+ if ( // $FlowFixMe[invalid-compare]
26
+ value === target || Array.isArray(value) && value.includes(target)) {
26
27
  throw new _Errors.InvalidStatementError(`Attempted to insert a statement into \`${parentWithType.type}.${key}\`.`);
27
28
  }
28
29
  }
@@ -135,6 +136,7 @@ function getStatementParent(target) {
135
136
 
136
137
  if ( // array insertions are already validated by the getAssertedIndex function
137
138
  result.targetIndex == null && // $FlowExpectedError[prop-missing]
139
+ // $FlowFixMe[invalid-compare]
138
140
  result.parent[result.key] !== target) {
139
141
  throw new _Errors.InvalidStatementError(`Expected to find the target "${target.type}" on the "${result.parent.type}.${result.key}", but found a different node. ` + 'This likely means that you attempted to mutate around the target after it was deleted/replaced.');
140
142
  }
@@ -45,6 +45,7 @@ export function getStatementParent(
45
45
  const value = parentWithType[key];
46
46
 
47
47
  if (
48
+ // $FlowFixMe[invalid-compare]
48
49
  value === target ||
49
50
  (Array.isArray(value) && value.includes(target))
50
51
  ) {
@@ -136,6 +137,7 @@ export function getStatementParent(
136
137
  // array insertions are already validated by the getAssertedIndex function
137
138
  result.targetIndex == null &&
138
139
  // $FlowExpectedError[prop-missing]
140
+ // $FlowFixMe[invalid-compare]
139
141
  result.parent[result.key] !== target
140
142
  ) {
141
143
  throw new InvalidStatementError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-transform",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Tools built on top of Hermes-ESTree to enable codebase transformation",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -12,9 +12,9 @@
12
12
  "@babel/code-frame": "^7.16.0",
13
13
  "esquery": "^1.4.0",
14
14
  "flow-enums-runtime": "^0.0.6",
15
- "hermes-eslint": "0.32.0",
16
- "hermes-estree": "0.32.0",
17
- "hermes-parser": "0.32.0",
15
+ "hermes-eslint": "0.33.0",
16
+ "hermes-estree": "0.33.0",
17
+ "hermes-parser": "0.33.0",
18
18
  "string-width": "4.2.3"
19
19
  },
20
20
  "peerDependencies": {