hermes-transform 0.20.1 → 0.21.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.
@@ -134,8 +134,7 @@ function detachedProps(parent, props, config = {}) {
134
134
  function shallowCloneNode(node, newProps, config = {}) {
135
135
  var _config$preserveLocat, _config$originalNode;
136
136
 
137
- return detachedProps(null, // $FlowFixMe[cannot-spread-interface]
138
- { ...node,
137
+ return detachedProps(null, { ...node,
139
138
  ...newProps
140
139
  }, {
141
140
  preserveLocation: (_config$preserveLocat = config.preserveLocation) != null ? _config$preserveLocat : true,
@@ -65,7 +65,7 @@ export const asDetachedNode: {
65
65
  return null;
66
66
  }
67
67
 
68
- if (isDetachedNode(node)) {
68
+ if (isDetachedNode((node: MaybeDetachedNode<T>))) {
69
69
  return node;
70
70
  }
71
71
 
@@ -77,7 +77,7 @@ export const asDetachedNode: {
77
77
  // used by the node type function codegen
78
78
  export function detachedProps<T: BaseNode>(
79
79
  parent: ?ESNode,
80
- props: $ReadOnly<Partial<{...}>>,
80
+ props: {...},
81
81
  config: DetachConfig = {},
82
82
  ): DetachedNode<T> {
83
83
  // $FlowExpectedError[incompatible-type]
@@ -144,13 +144,12 @@ export function detachedProps<T: BaseNode>(
144
144
  */
145
145
  export function shallowCloneNode<T: ESNode>(
146
146
  node: T,
147
- newProps: $ReadOnly<Partial<{...}>>,
147
+ newProps: {...},
148
148
  config?: DetachConfig = {},
149
149
  ): DetachedNode<T> {
150
- return detachedProps(
150
+ return detachedProps<T>(
151
151
  null,
152
- // $FlowFixMe[cannot-spread-interface]
153
- {...node, ...newProps},
152
+ {...(node: $FlowFixMe), ...newProps},
154
153
  {
155
154
  preserveLocation: config.preserveLocation ?? true,
156
155
  originalNode: config.originalNode ?? node,
@@ -163,7 +162,7 @@ export function shallowCloneNode<T: ESNode>(
163
162
  */
164
163
  export function deepCloneNode<T: ESNode>(
165
164
  node: T,
166
- newProps: $ReadOnly<Partial<{...}>>,
165
+ newProps: {...},
167
166
  ): DetachedNode<T> {
168
167
  const clone: DetachedNode<T> = Object.assign(
169
168
  JSON.parse(
@@ -181,7 +180,7 @@ export function deepCloneNode<T: ESNode>(
181
180
  updateAllParentPointers(clone);
182
181
 
183
182
  // $FlowExpectedError[class-object-subtyping]
184
- return detachedProps(null, clone);
183
+ return detachedProps<T>(null, clone);
185
184
  }
186
185
 
187
186
  /**
@@ -17,7 +17,7 @@
17
17
 
18
18
  // lint directives to let us do some basic validation of generated files
19
19
  /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
- /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
20
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
21
21
 
22
22
  'use strict';
23
23
 
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsConstExpression,
30
31
  AsExpression,
31
32
  AssignmentExpression,
32
33
  AssignmentPattern,
@@ -73,6 +74,8 @@ import type {
73
74
  DoWhileStatement,
74
75
  EmptyStatement,
75
76
  EmptyTypeAnnotation,
77
+ EnumBigIntBody,
78
+ EnumBigIntMember,
76
79
  EnumBooleanBody,
77
80
  EnumBooleanMember,
78
81
  EnumDeclaration,
@@ -206,6 +209,7 @@ import type {
206
209
  ArrayPatternProps,
207
210
  ArrayTypeAnnotationProps,
208
211
  ArrowFunctionExpressionProps,
212
+ AsConstExpressionProps,
209
213
  AsExpressionProps,
210
214
  AssignmentExpressionProps,
211
215
  AssignmentPatternProps,
@@ -252,6 +256,8 @@ import type {
252
256
  DoWhileStatementProps,
253
257
  EmptyStatementProps,
254
258
  EmptyTypeAnnotationProps,
259
+ EnumBigIntBodyProps,
260
+ EnumBigIntMemberProps,
255
261
  EnumBooleanBodyProps,
256
262
  EnumBooleanMemberProps,
257
263
  EnumDeclarationProps,
@@ -421,6 +427,14 @@ type ArrowFunctionExpressionCloneSignature = ((
421
427
  node: ?ArrowFunctionExpression,
422
428
  newProps: Partial<ArrowFunctionExpressionProps>,
423
429
  ) => DetachedNode<ArrowFunctionExpression> | null);
430
+ type AsConstExpressionCloneSignature = ((
431
+ node: AsConstExpression,
432
+ newProps: Partial<AsConstExpressionProps>,
433
+ ) => DetachedNode<AsConstExpression>) &
434
+ ((
435
+ node: ?AsConstExpression,
436
+ newProps: Partial<AsConstExpressionProps>,
437
+ ) => DetachedNode<AsConstExpression> | null);
424
438
  type AsExpressionCloneSignature = ((
425
439
  node: AsExpression,
426
440
  newProps: Partial<AsExpressionProps>,
@@ -789,6 +803,22 @@ type EmptyTypeAnnotationCloneSignature = ((
789
803
  node: ?EmptyTypeAnnotation,
790
804
  newProps: Partial<EmptyTypeAnnotationProps>,
791
805
  ) => DetachedNode<EmptyTypeAnnotation> | null);
806
+ type EnumBigIntBodyCloneSignature = ((
807
+ node: EnumBigIntBody,
808
+ newProps: Partial<EnumBigIntBodyProps>,
809
+ ) => DetachedNode<EnumBigIntBody>) &
810
+ ((
811
+ node: ?EnumBigIntBody,
812
+ newProps: Partial<EnumBigIntBodyProps>,
813
+ ) => DetachedNode<EnumBigIntBody> | null);
814
+ type EnumBigIntMemberCloneSignature = ((
815
+ node: EnumBigIntMember,
816
+ newProps: Partial<EnumBigIntMemberProps>,
817
+ ) => DetachedNode<EnumBigIntMember>) &
818
+ ((
819
+ node: ?EnumBigIntMember,
820
+ newProps: Partial<EnumBigIntMemberProps>,
821
+ ) => DetachedNode<EnumBigIntMember> | null);
792
822
  type EnumBooleanBodyCloneSignature = ((
793
823
  node: EnumBooleanBody,
794
824
  newProps: Partial<EnumBooleanBodyProps>,
@@ -1799,6 +1829,7 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
1799
1829
  ArrayPatternCloneSignature &
1800
1830
  ArrayTypeAnnotationCloneSignature &
1801
1831
  ArrowFunctionExpressionCloneSignature &
1832
+ AsConstExpressionCloneSignature &
1802
1833
  AsExpressionCloneSignature &
1803
1834
  AssignmentExpressionCloneSignature &
1804
1835
  AssignmentPatternCloneSignature &
@@ -1845,6 +1876,8 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
1845
1876
  DoWhileStatementCloneSignature &
1846
1877
  EmptyStatementCloneSignature &
1847
1878
  EmptyTypeAnnotationCloneSignature &
1879
+ EnumBigIntBodyCloneSignature &
1880
+ EnumBigIntMemberCloneSignature &
1848
1881
  EnumBooleanBodyCloneSignature &
1849
1882
  EnumBooleanMemberCloneSignature &
1850
1883
  EnumDeclarationCloneSignature &
@@ -17,7 +17,7 @@
17
17
 
18
18
  // lint directives to let us do some basic validation of generated files
19
19
  /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
- /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
20
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
21
21
 
22
22
  'use strict';
23
23
 
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsConstExpression,
30
31
  AsExpression,
31
32
  AssignmentExpression,
32
33
  AssignmentPattern,
@@ -73,6 +74,8 @@ import type {
73
74
  DoWhileStatement,
74
75
  EmptyStatement,
75
76
  EmptyTypeAnnotation,
77
+ EnumBigIntBody,
78
+ EnumBigIntMember,
76
79
  EnumBooleanBody,
77
80
  EnumBooleanMember,
78
81
  EnumDeclaration,
@@ -206,6 +209,7 @@ import type {
206
209
  ArrayPatternProps,
207
210
  ArrayTypeAnnotationProps,
208
211
  ArrowFunctionExpressionProps,
212
+ AsConstExpressionProps,
209
213
  AsExpressionProps,
210
214
  AssignmentExpressionProps,
211
215
  AssignmentPatternProps,
@@ -252,6 +256,8 @@ import type {
252
256
  DoWhileStatementProps,
253
257
  EmptyStatementProps,
254
258
  EmptyTypeAnnotationProps,
259
+ EnumBigIntBodyProps,
260
+ EnumBigIntMemberProps,
255
261
  EnumBooleanBodyProps,
256
262
  EnumBooleanMemberProps,
257
263
  EnumDeclarationProps,
@@ -400,6 +406,10 @@ type ArrowFunctionExpressionModifySignature = (
400
406
  node: ?ArrowFunctionExpression,
401
407
  newProps: Partial<ArrowFunctionExpressionProps>,
402
408
  ) => void;
409
+ type AsConstExpressionModifySignature = (
410
+ node: ?AsConstExpression,
411
+ newProps: Partial<AsConstExpressionProps>,
412
+ ) => void;
403
413
  type AsExpressionModifySignature = (
404
414
  node: ?AsExpression,
405
415
  newProps: Partial<AsExpressionProps>,
@@ -584,6 +594,14 @@ type EmptyTypeAnnotationModifySignature = (
584
594
  node: ?EmptyTypeAnnotation,
585
595
  newProps: Partial<EmptyTypeAnnotationProps>,
586
596
  ) => void;
597
+ type EnumBigIntBodyModifySignature = (
598
+ node: ?EnumBigIntBody,
599
+ newProps: Partial<EnumBigIntBodyProps>,
600
+ ) => void;
601
+ type EnumBigIntMemberModifySignature = (
602
+ node: ?EnumBigIntMember,
603
+ newProps: Partial<EnumBigIntMemberProps>,
604
+ ) => void;
587
605
  type EnumBooleanBodyModifySignature = (
588
606
  node: ?EnumBooleanBody,
589
607
  newProps: Partial<EnumBooleanBodyProps>,
@@ -1093,6 +1111,7 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
1093
1111
  ArrayPatternModifySignature &
1094
1112
  ArrayTypeAnnotationModifySignature &
1095
1113
  ArrowFunctionExpressionModifySignature &
1114
+ AsConstExpressionModifySignature &
1096
1115
  AsExpressionModifySignature &
1097
1116
  AssignmentExpressionModifySignature &
1098
1117
  AssignmentPatternModifySignature &
@@ -1139,6 +1158,8 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
1139
1158
  DoWhileStatementModifySignature &
1140
1159
  EmptyStatementModifySignature &
1141
1160
  EmptyTypeAnnotationModifySignature &
1161
+ EnumBigIntBodyModifySignature &
1162
+ EnumBigIntMemberModifySignature &
1142
1163
  EnumBooleanBodyModifySignature &
1143
1164
  EnumBooleanMemberModifySignature &
1144
1165
  EnumDeclarationModifySignature &
@@ -17,7 +17,7 @@
17
17
 
18
18
  // lint directives to let us do some basic validation of generated files
19
19
  /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
- /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
20
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
21
21
 
22
22
  'use strict';
23
23
 
@@ -27,6 +27,7 @@ import type {
27
27
  ArrayPattern,
28
28
  ArrayTypeAnnotation,
29
29
  ArrowFunctionExpression,
30
+ AsConstExpression,
30
31
  AsExpression,
31
32
  AssignmentExpression,
32
33
  AssignmentPattern,
@@ -71,6 +72,8 @@ import type {
71
72
  DoWhileStatement,
72
73
  EmptyStatement,
73
74
  EmptyTypeAnnotation,
75
+ EnumBigIntBody,
76
+ EnumBigIntMember,
74
77
  EnumBooleanBody,
75
78
  EnumBooleanMember,
76
79
  EnumDeclaration,
@@ -223,6 +226,11 @@ type ArrowFunctionExpressionReplaceSignature = (
223
226
  nodeToReplaceWith: DetachedNode<ArrowFunctionExpression>,
224
227
  options?: $ReadOnly<{keepComments?: boolean}>,
225
228
  ) => void;
229
+ type AsConstExpressionReplaceSignature = (
230
+ target: AsConstExpression,
231
+ nodeToReplaceWith: DetachedNode<AsConstExpression>,
232
+ options?: $ReadOnly<{keepComments?: boolean}>,
233
+ ) => void;
226
234
  type AsExpressionReplaceSignature = (
227
235
  target: AsExpression,
228
236
  nodeToReplaceWith: DetachedNode<AsExpression>,
@@ -443,6 +451,16 @@ type EmptyTypeAnnotationReplaceSignature = (
443
451
  nodeToReplaceWith: DetachedNode<EmptyTypeAnnotation>,
444
452
  options?: $ReadOnly<{keepComments?: boolean}>,
445
453
  ) => void;
454
+ type EnumBigIntBodyReplaceSignature = (
455
+ target: EnumBigIntBody,
456
+ nodeToReplaceWith: DetachedNode<EnumBigIntBody>,
457
+ options?: $ReadOnly<{keepComments?: boolean}>,
458
+ ) => void;
459
+ type EnumBigIntMemberReplaceSignature = (
460
+ target: EnumBigIntMember,
461
+ nodeToReplaceWith: DetachedNode<EnumBigIntMember>,
462
+ options?: $ReadOnly<{keepComments?: boolean}>,
463
+ ) => void;
446
464
  type EnumBooleanBodyReplaceSignature = (
447
465
  target: EnumBooleanBody,
448
466
  nodeToReplaceWith: DetachedNode<EnumBooleanBody>,
@@ -1068,6 +1086,7 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
1068
1086
  ArrayPatternReplaceSignature &
1069
1087
  ArrayTypeAnnotationReplaceSignature &
1070
1088
  ArrowFunctionExpressionReplaceSignature &
1089
+ AsConstExpressionReplaceSignature &
1071
1090
  AsExpressionReplaceSignature &
1072
1091
  AssignmentExpressionReplaceSignature &
1073
1092
  AssignmentPatternReplaceSignature &
@@ -1112,6 +1131,8 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
1112
1131
  DoWhileStatementReplaceSignature &
1113
1132
  EmptyStatementReplaceSignature &
1114
1133
  EmptyTypeAnnotationReplaceSignature &
1134
+ EnumBigIntBodyReplaceSignature &
1135
+ EnumBigIntMemberReplaceSignature &
1115
1136
  EnumBooleanBodyReplaceSignature &
1116
1137
  EnumBooleanMemberReplaceSignature &
1117
1138
  EnumDeclarationReplaceSignature &
@@ -18,7 +18,7 @@
18
18
 
19
19
  /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
20
 
21
- /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
21
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
22
22
  'use strict';
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
@@ -29,6 +29,7 @@ var _exportNames = {
29
29
  ArrayExpression: true,
30
30
  ArrayPattern: true,
31
31
  ArrayTypeAnnotation: true,
32
+ AsConstExpression: true,
32
33
  AsExpression: true,
33
34
  AssignmentExpression: true,
34
35
  AssignmentPattern: true,
@@ -69,6 +70,8 @@ var _exportNames = {
69
70
  DoWhileStatement: true,
70
71
  EmptyStatement: true,
71
72
  EmptyTypeAnnotation: true,
73
+ EnumBigIntBody: true,
74
+ EnumBigIntMember: true,
72
75
  EnumBooleanBody: true,
73
76
  EnumBooleanMember: true,
74
77
  EnumDeclaration: true,
@@ -191,6 +194,7 @@ exports.AnyTypeAnnotation = AnyTypeAnnotation;
191
194
  exports.ArrayExpression = ArrayExpression;
192
195
  exports.ArrayPattern = ArrayPattern;
193
196
  exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
197
+ exports.AsConstExpression = AsConstExpression;
194
198
  exports.AsExpression = AsExpression;
195
199
  exports.AssignmentExpression = AssignmentExpression;
196
200
  exports.AssignmentPattern = AssignmentPattern;
@@ -231,6 +235,8 @@ exports.DeclaredPredicate = DeclaredPredicate;
231
235
  exports.DoWhileStatement = DoWhileStatement;
232
236
  exports.EmptyStatement = EmptyStatement;
233
237
  exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
238
+ exports.EnumBigIntBody = EnumBigIntBody;
239
+ exports.EnumBigIntMember = EnumBigIntMember;
234
240
  exports.EnumBooleanBody = EnumBooleanBody;
235
241
  exports.EnumBooleanMember = EnumBooleanMember;
236
242
  exports.EnumDeclaration = EnumDeclaration;
@@ -396,6 +402,15 @@ function ArrayTypeAnnotation(props) {
396
402
  return node;
397
403
  }
398
404
 
405
+ function AsConstExpression(props) {
406
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
407
+ type: 'AsConstExpression',
408
+ expression: (0, _detachedNode.asDetachedNodeForCodeGen)(props.expression)
409
+ });
410
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
411
+ return node;
412
+ }
413
+
399
414
  function AsExpression(props) {
400
415
  const node = (0, _detachedNode.detachedProps)(props.parent, {
401
416
  type: 'AsExpression',
@@ -801,6 +816,27 @@ function EmptyTypeAnnotation(props = { ...null
801
816
  });
802
817
  }
803
818
 
819
+ function EnumBigIntBody(props) {
820
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
821
+ type: 'EnumBigIntBody',
822
+ members: props.members.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
823
+ explicitType: props.explicitType,
824
+ hasUnknownMembers: props.hasUnknownMembers
825
+ });
826
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
827
+ return node;
828
+ }
829
+
830
+ function EnumBigIntMember(props) {
831
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
832
+ type: 'EnumBigIntMember',
833
+ id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
834
+ init: (0, _detachedNode.asDetachedNodeForCodeGen)(props.init)
835
+ });
836
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
837
+ return node;
838
+ }
839
+
804
840
  function EnumBooleanBody(props) {
805
841
  const node = (0, _detachedNode.detachedProps)(props.parent, {
806
842
  type: 'EnumBooleanBody',
@@ -1768,7 +1804,8 @@ function TryStatement(props) {
1768
1804
  function TupleTypeAnnotation(props) {
1769
1805
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1770
1806
  type: 'TupleTypeAnnotation',
1771
- types: props.types.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n))
1807
+ types: props.types.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1808
+ inexact: props.inexact
1772
1809
  });
1773
1810
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1774
1811
  return node;
@@ -1882,7 +1919,7 @@ function TypePredicate(props) {
1882
1919
  type: 'TypePredicate',
1883
1920
  parameterName: (0, _detachedNode.asDetachedNodeForCodeGen)(props.parameterName),
1884
1921
  typeAnnotation: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeAnnotation),
1885
- asserts: props.asserts
1922
+ kind: props.kind
1886
1923
  });
1887
1924
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1888
1925
  return node;