hermes-transform 0.16.0 → 0.17.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.
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsExpression,
30
31
  AssignmentExpression,
31
32
  AssignmentPattern,
32
33
  AwaitExpression,
@@ -201,6 +202,7 @@ import type {
201
202
  ArrayPatternProps,
202
203
  ArrayTypeAnnotationProps,
203
204
  ArrowFunctionExpressionProps,
205
+ AsExpressionProps,
204
206
  AssignmentExpressionProps,
205
207
  AssignmentPatternProps,
206
208
  AwaitExpressionProps,
@@ -411,6 +413,14 @@ type ArrowFunctionExpressionCloneSignature = ((
411
413
  node: ?ArrowFunctionExpression,
412
414
  newProps: Partial<ArrowFunctionExpressionProps>,
413
415
  ) => DetachedNode<ArrowFunctionExpression> | null);
416
+ type AsExpressionCloneSignature = ((
417
+ node: AsExpression,
418
+ newProps: Partial<AsExpressionProps>,
419
+ ) => DetachedNode<AsExpression>) &
420
+ ((
421
+ node: ?AsExpression,
422
+ newProps: Partial<AsExpressionProps>,
423
+ ) => DetachedNode<AsExpression> | null);
414
424
  type AssignmentExpressionCloneSignature = ((
415
425
  node: AssignmentExpression,
416
426
  newProps: Partial<AssignmentExpressionProps>,
@@ -1749,6 +1759,7 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
1749
1759
  ArrayPatternCloneSignature &
1750
1760
  ArrayTypeAnnotationCloneSignature &
1751
1761
  ArrowFunctionExpressionCloneSignature &
1762
+ AsExpressionCloneSignature &
1752
1763
  AssignmentExpressionCloneSignature &
1753
1764
  AssignmentPatternCloneSignature &
1754
1765
  AwaitExpressionCloneSignature &
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsExpression,
30
31
  AssignmentExpression,
31
32
  AssignmentPattern,
32
33
  AwaitExpression,
@@ -201,6 +202,7 @@ import type {
201
202
  ArrayPatternProps,
202
203
  ArrayTypeAnnotationProps,
203
204
  ArrowFunctionExpressionProps,
205
+ AsExpressionProps,
204
206
  AssignmentExpressionProps,
205
207
  AssignmentPatternProps,
206
208
  AwaitExpressionProps,
@@ -390,6 +392,10 @@ type ArrowFunctionExpressionModifySignature = (
390
392
  node: ?ArrowFunctionExpression,
391
393
  newProps: Partial<ArrowFunctionExpressionProps>,
392
394
  ) => void;
395
+ type AsExpressionModifySignature = (
396
+ node: ?AsExpression,
397
+ newProps: Partial<AsExpressionProps>,
398
+ ) => void;
393
399
  type AssignmentExpressionModifySignature = (
394
400
  node: ?AssignmentExpression,
395
401
  newProps: Partial<AssignmentExpressionProps>,
@@ -1063,6 +1069,7 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
1063
1069
  ArrayPatternModifySignature &
1064
1070
  ArrayTypeAnnotationModifySignature &
1065
1071
  ArrowFunctionExpressionModifySignature &
1072
+ AsExpressionModifySignature &
1066
1073
  AssignmentExpressionModifySignature &
1067
1074
  AssignmentPatternModifySignature &
1068
1075
  AwaitExpressionModifySignature &
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsExpression,
30
31
  AssignmentExpression,
31
32
  AssignmentPattern,
32
33
  AwaitExpression,
@@ -218,6 +219,11 @@ type ArrowFunctionExpressionReplaceSignature = (
218
219
  nodeToReplaceWith: DetachedNode<ArrowFunctionExpression>,
219
220
  options?: $ReadOnly<{keepComments?: boolean}>,
220
221
  ) => void;
222
+ type AsExpressionReplaceSignature = (
223
+ target: AsExpression,
224
+ nodeToReplaceWith: DetachedNode<AsExpression>,
225
+ options?: $ReadOnly<{keepComments?: boolean}>,
226
+ ) => void;
221
227
  type AssignmentExpressionReplaceSignature = (
222
228
  target: AssignmentExpression,
223
229
  nodeToReplaceWith: DetachedNode<AssignmentExpression>,
@@ -1038,6 +1044,7 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
1038
1044
  ArrayPatternReplaceSignature &
1039
1045
  ArrayTypeAnnotationReplaceSignature &
1040
1046
  ArrowFunctionExpressionReplaceSignature &
1047
+ AsExpressionReplaceSignature &
1041
1048
  AssignmentExpressionReplaceSignature &
1042
1049
  AssignmentPatternReplaceSignature &
1043
1050
  AwaitExpressionReplaceSignature &
@@ -29,6 +29,7 @@ var _exportNames = {
29
29
  ArrayExpression: true,
30
30
  ArrayPattern: true,
31
31
  ArrayTypeAnnotation: true,
32
+ AsExpression: true,
32
33
  AssignmentExpression: true,
33
34
  AssignmentPattern: true,
34
35
  AwaitExpression: true,
@@ -187,6 +188,7 @@ exports.AnyTypeAnnotation = AnyTypeAnnotation;
187
188
  exports.ArrayExpression = ArrayExpression;
188
189
  exports.ArrayPattern = ArrayPattern;
189
190
  exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
191
+ exports.AsExpression = AsExpression;
190
192
  exports.AssignmentExpression = AssignmentExpression;
191
193
  exports.AssignmentPattern = AssignmentPattern;
192
194
  exports.AwaitExpression = AwaitExpression;
@@ -388,6 +390,16 @@ function ArrayTypeAnnotation(props) {
388
390
  return node;
389
391
  }
390
392
 
393
+ function AsExpression(props) {
394
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
395
+ type: 'AsExpression',
396
+ expression: (0, _detachedNode.asDetachedNodeForCodeGen)(props.expression),
397
+ typeAnnotation: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeAnnotation)
398
+ });
399
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
400
+ return node;
401
+ }
402
+
391
403
  function AssignmentExpression(props) {
392
404
  const node = (0, _detachedNode.detachedProps)(props.parent, {
393
405
  type: 'AssignmentExpression',
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayExpression as ArrayExpressionType,
28
28
  ArrayPattern as ArrayPatternType,
29
29
  ArrayTypeAnnotation as ArrayTypeAnnotationType,
30
+ AsExpression as AsExpressionType,
30
31
  AssignmentExpression as AssignmentExpressionType,
31
32
  AssignmentPattern as AssignmentPatternType,
32
33
  AwaitExpression as AwaitExpressionType,
@@ -209,6 +210,11 @@ export type ArrayTypeAnnotationProps = {
209
210
  +elementType: MaybeDetachedNode<ArrayTypeAnnotationType['elementType']>,
210
211
  };
211
212
 
213
+ export type AsExpressionProps = {
214
+ +expression: MaybeDetachedNode<AsExpressionType['expression']>,
215
+ +typeAnnotation: MaybeDetachedNode<AsExpressionType['typeAnnotation']>,
216
+ };
217
+
212
218
  export type AssignmentExpressionProps = {
213
219
  +operator: AssignmentExpressionType['operator'],
214
220
  +left: MaybeDetachedNode<AssignmentExpressionType['left']>,
@@ -1150,6 +1156,19 @@ export function ArrayTypeAnnotation(props: {
1150
1156
  return node;
1151
1157
  }
1152
1158
 
1159
+ export function AsExpression(props: {
1160
+ ...$ReadOnly<AsExpressionProps>,
1161
+ +parent?: ESNode,
1162
+ }): DetachedNode<AsExpressionType> {
1163
+ const node = detachedProps<AsExpressionType>(props.parent, {
1164
+ type: 'AsExpression',
1165
+ expression: asDetachedNodeForCodeGen(props.expression),
1166
+ typeAnnotation: asDetachedNodeForCodeGen(props.typeAnnotation),
1167
+ });
1168
+ setParentPointersInDirectChildren(node);
1169
+ return node;
1170
+ }
1171
+
1153
1172
  export function AssignmentExpression(props: {
1154
1173
  ...$ReadOnly<AssignmentExpressionProps>,
1155
1174
  +parent?: ESNode,
@@ -34,6 +34,7 @@ function ExportNamedDeclarationWithSpecifiers(props) {
34
34
  type: 'ExportNamedDeclaration',
35
35
  declaration: null,
36
36
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
37
+ // $FlowFixMe[incompatible-call]
37
38
  source: (0, _detachedNode.asDetachedNode)(props.source),
38
39
  exportKind: props.exportKind
39
40
  });
@@ -66,6 +66,7 @@ export function ExportNamedDeclarationWithSpecifiers(props: {
66
66
  type: 'ExportNamedDeclaration',
67
67
  declaration: null,
68
68
  specifiers: props.specifiers.map(n => asDetachedNode(n)),
69
+ // $FlowFixMe[incompatible-call]
69
70
  source: asDetachedNode(props.source),
70
71
  exportKind: props.exportKind,
71
72
  },
@@ -48,6 +48,7 @@ function ObjectTypePropertySignature(props) {
48
48
  proto: (_props$proto2 = props.proto) != null ? _props$proto2 : false,
49
49
  static: (_props$static2 = props.static) != null ? _props$static2 : false,
50
50
  value: (0, _detachedNode.asDetachedNode)(props.value),
51
+ // $FlowFixMe[incompatible-call]
51
52
  variance: (0, _detachedNode.asDetachedNode)(props.variance)
52
53
  });
53
54
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -72,6 +72,7 @@ export function ObjectTypePropertySignature(props: {
72
72
  proto: props.proto ?? false,
73
73
  static: props.static ?? false,
74
74
  value: asDetachedNode(props.value),
75
+ // $FlowFixMe[incompatible-call]
75
76
  variance: asDetachedNode(props.variance),
76
77
  });
77
78
  setParentPointersInDirectChildren(node);
@@ -30,8 +30,11 @@ function ArrowFunctionExpression(props) {
30
30
  expression: props.body.type !== 'BlockStatement',
31
31
  params: props.params.map(n => (0, _detachedNode.asDetachedNode)(n)),
32
32
  body: (0, _detachedNode.asDetachedNode)(props.body),
33
+ // $FlowFixMe[incompatible-call]
33
34
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
35
+ // $FlowFixMe[incompatible-call]
34
36
  returnType: (0, _detachedNode.asDetachedNode)(props.returnType),
37
+ // $FlowFixMe[incompatible-call]
35
38
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate),
36
39
  async: props.async
37
40
  });
@@ -44,9 +47,13 @@ function ClassDeclaration(props) {
44
47
 
45
48
  const node = (0, _detachedNode.detachedProps)(props.parent, {
46
49
  type: 'ClassDeclaration',
50
+ // $FlowFixMe[incompatible-call]
47
51
  id: (0, _detachedNode.asDetachedNode)(props.id),
52
+ // $FlowFixMe[incompatible-call]
48
53
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
54
+ // $FlowFixMe[incompatible-call]
49
55
  superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
56
+ // $FlowFixMe[incompatible-call]
50
57
  superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
51
58
  decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
52
59
  implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
@@ -77,6 +84,7 @@ function Identifier(props) {
77
84
  type: 'Identifier',
78
85
  name: props.name,
79
86
  optional: (_props$optional = props.optional) != null ? _props$optional : false,
87
+ // $FlowFixMe[incompatible-call]
80
88
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.typeAnnotation)
81
89
  });
82
90
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -113,6 +121,7 @@ function DeclareFunction(props) {
113
121
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.functionType)
114
122
  })
115
123
  }),
124
+ // $FlowFixMe[incompatible-call]
116
125
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate)
117
126
  });
118
127
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -63,8 +63,11 @@ export function ArrowFunctionExpression(props: {
63
63
  expression: props.body.type !== 'BlockStatement',
64
64
  params: props.params.map(n => asDetachedNode(n)),
65
65
  body: asDetachedNode(props.body),
66
+ // $FlowFixMe[incompatible-call]
66
67
  typeParameters: asDetachedNode(props.typeParameters),
68
+ // $FlowFixMe[incompatible-call]
67
69
  returnType: asDetachedNode(props.returnType),
70
+ // $FlowFixMe[incompatible-call]
68
71
  predicate: asDetachedNode(props.predicate),
69
72
  async: props.async,
70
73
  });
@@ -95,9 +98,13 @@ export function ClassDeclaration(props: {
95
98
  }): DetachedNode<ClassDeclarationType> {
96
99
  const node = detachedProps<ClassDeclarationType>(props.parent, {
97
100
  type: 'ClassDeclaration',
101
+ // $FlowFixMe[incompatible-call]
98
102
  id: asDetachedNode(props.id),
103
+ // $FlowFixMe[incompatible-call]
99
104
  typeParameters: asDetachedNode(props.typeParameters),
105
+ // $FlowFixMe[incompatible-call]
100
106
  superClass: asDetachedNode(props.superClass),
107
+ // $FlowFixMe[incompatible-call]
101
108
  superTypeParameters: asDetachedNode(props.superTypeParameters),
102
109
  decorators: (props.decorators ?? []).map(n => asDetachedNode(n)),
103
110
  implements: (props.implements ?? []).map(n => asDetachedNode(n)),
@@ -142,6 +149,7 @@ export function Identifier(props: {
142
149
  type: 'Identifier',
143
150
  name: props.name,
144
151
  optional: props.optional ?? false,
152
+ // $FlowFixMe[incompatible-call]
145
153
  typeAnnotation: asDetachedNode(props.typeAnnotation),
146
154
  });
147
155
  setParentPointersInDirectChildren(node);
@@ -199,6 +207,7 @@ export function DeclareFunction(props: {
199
207
  typeAnnotation: asDetachedNode(props.functionType),
200
208
  }),
201
209
  }),
210
+ // $FlowFixMe[incompatible-call]
202
211
  predicate: asDetachedNode(props.predicate),
203
212
  });
204
213
  setParentPointersInDirectChildren(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-transform",
3
- "version": "0.16.0",
3
+ "version": "0.17.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,13 +12,13 @@
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.16.0",
16
- "hermes-estree": "0.16.0",
17
- "hermes-parser": "0.16.0"
15
+ "hermes-eslint": "0.17.0",
16
+ "hermes-estree": "0.17.0",
17
+ "hermes-parser": "0.17.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "prettier": "^3.0.0 || ^2.7.1",
21
- "prettier-plugin-hermes-parser": "0.16.0"
21
+ "prettier-plugin-hermes-parser": "0.17.0"
22
22
  },
23
23
  "files": [
24
24
  "dist",