hermes-transform 0.18.2 → 0.19.1
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.
- package/dist/generated/TransformCloneSignatures.js.flow +44 -0
- package/dist/generated/TransformModifySignatures.js.flow +28 -0
- package/dist/generated/TransformReplaceSignatures.js.flow +28 -0
- package/dist/generated/node-types.js +44 -3
- package/dist/generated/node-types.js.flow +77 -2
- package/dist/generated/special-case-node-types/DeclareHook.js +33 -0
- package/dist/generated/special-case-node-types/DeclareHook.js.flow +48 -0
- package/dist/generated/special-case-node-types.js +8 -0
- package/dist/generated/special-case-node-types.js.flow +1 -0
- package/package.json +5 -5
|
@@ -62,9 +62,11 @@ import type {
|
|
|
62
62
|
DeclareExportAllDeclaration,
|
|
63
63
|
DeclareExportDeclaration,
|
|
64
64
|
DeclareFunction,
|
|
65
|
+
DeclareHook,
|
|
65
66
|
DeclareInterface,
|
|
66
67
|
DeclareModule,
|
|
67
68
|
DeclareModuleExports,
|
|
69
|
+
DeclareNamespace,
|
|
68
70
|
DeclareOpaqueType,
|
|
69
71
|
DeclareTypeAlias,
|
|
70
72
|
DeclareVariable,
|
|
@@ -94,6 +96,8 @@ import type {
|
|
|
94
96
|
FunctionTypeAnnotation,
|
|
95
97
|
FunctionTypeParam,
|
|
96
98
|
GenericTypeAnnotation,
|
|
99
|
+
HookDeclaration,
|
|
100
|
+
HookTypeAnnotation,
|
|
97
101
|
Identifier,
|
|
98
102
|
IfStatement,
|
|
99
103
|
ImportAttribute,
|
|
@@ -237,9 +241,11 @@ import type {
|
|
|
237
241
|
DeclareExportAllDeclarationProps,
|
|
238
242
|
DeclareExportDeclarationProps,
|
|
239
243
|
DeclareFunctionProps,
|
|
244
|
+
DeclareHookProps,
|
|
240
245
|
DeclareInterfaceProps,
|
|
241
246
|
DeclareModuleProps,
|
|
242
247
|
DeclareModuleExportsProps,
|
|
248
|
+
DeclareNamespaceProps,
|
|
243
249
|
DeclareOpaqueTypeProps,
|
|
244
250
|
DeclareTypeAliasProps,
|
|
245
251
|
DeclareVariableProps,
|
|
@@ -269,6 +275,8 @@ import type {
|
|
|
269
275
|
FunctionTypeAnnotationProps,
|
|
270
276
|
FunctionTypeParamProps,
|
|
271
277
|
GenericTypeAnnotationProps,
|
|
278
|
+
HookDeclarationProps,
|
|
279
|
+
HookTypeAnnotationProps,
|
|
272
280
|
IdentifierProps,
|
|
273
281
|
IfStatementProps,
|
|
274
282
|
ImportAttributeProps,
|
|
@@ -693,6 +701,14 @@ type DeclareFunctionCloneSignature = ((
|
|
|
693
701
|
node: ?DeclareFunction,
|
|
694
702
|
newProps: Partial<DeclareFunctionProps>,
|
|
695
703
|
) => DetachedNode<DeclareFunction> | null);
|
|
704
|
+
type DeclareHookCloneSignature = ((
|
|
705
|
+
node: DeclareHook,
|
|
706
|
+
newProps: Partial<DeclareHookProps>,
|
|
707
|
+
) => DetachedNode<DeclareHook>) &
|
|
708
|
+
((
|
|
709
|
+
node: ?DeclareHook,
|
|
710
|
+
newProps: Partial<DeclareHookProps>,
|
|
711
|
+
) => DetachedNode<DeclareHook> | null);
|
|
696
712
|
type DeclareInterfaceCloneSignature = ((
|
|
697
713
|
node: DeclareInterface,
|
|
698
714
|
newProps: Partial<DeclareInterfaceProps>,
|
|
@@ -717,6 +733,14 @@ type DeclareModuleExportsCloneSignature = ((
|
|
|
717
733
|
node: ?DeclareModuleExports,
|
|
718
734
|
newProps: Partial<DeclareModuleExportsProps>,
|
|
719
735
|
) => DetachedNode<DeclareModuleExports> | null);
|
|
736
|
+
type DeclareNamespaceCloneSignature = ((
|
|
737
|
+
node: DeclareNamespace,
|
|
738
|
+
newProps: Partial<DeclareNamespaceProps>,
|
|
739
|
+
) => DetachedNode<DeclareNamespace>) &
|
|
740
|
+
((
|
|
741
|
+
node: ?DeclareNamespace,
|
|
742
|
+
newProps: Partial<DeclareNamespaceProps>,
|
|
743
|
+
) => DetachedNode<DeclareNamespace> | null);
|
|
720
744
|
type DeclareOpaqueTypeCloneSignature = ((
|
|
721
745
|
node: DeclareOpaqueType,
|
|
722
746
|
newProps: Partial<DeclareOpaqueTypeProps>,
|
|
@@ -949,6 +973,22 @@ type GenericTypeAnnotationCloneSignature = ((
|
|
|
949
973
|
node: ?GenericTypeAnnotation,
|
|
950
974
|
newProps: Partial<GenericTypeAnnotationProps>,
|
|
951
975
|
) => DetachedNode<GenericTypeAnnotation> | null);
|
|
976
|
+
type HookDeclarationCloneSignature = ((
|
|
977
|
+
node: HookDeclaration,
|
|
978
|
+
newProps: Partial<HookDeclarationProps>,
|
|
979
|
+
) => DetachedNode<HookDeclaration>) &
|
|
980
|
+
((
|
|
981
|
+
node: ?HookDeclaration,
|
|
982
|
+
newProps: Partial<HookDeclarationProps>,
|
|
983
|
+
) => DetachedNode<HookDeclaration> | null);
|
|
984
|
+
type HookTypeAnnotationCloneSignature = ((
|
|
985
|
+
node: HookTypeAnnotation,
|
|
986
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
987
|
+
) => DetachedNode<HookTypeAnnotation>) &
|
|
988
|
+
((
|
|
989
|
+
node: ?HookTypeAnnotation,
|
|
990
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
991
|
+
) => DetachedNode<HookTypeAnnotation> | null);
|
|
952
992
|
type IdentifierCloneSignature = ((
|
|
953
993
|
node: Identifier,
|
|
954
994
|
newProps: Partial<IdentifierProps>,
|
|
@@ -1794,9 +1834,11 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
|
|
|
1794
1834
|
DeclareExportAllDeclarationCloneSignature &
|
|
1795
1835
|
DeclareExportDeclarationCloneSignature &
|
|
1796
1836
|
DeclareFunctionCloneSignature &
|
|
1837
|
+
DeclareHookCloneSignature &
|
|
1797
1838
|
DeclareInterfaceCloneSignature &
|
|
1798
1839
|
DeclareModuleCloneSignature &
|
|
1799
1840
|
DeclareModuleExportsCloneSignature &
|
|
1841
|
+
DeclareNamespaceCloneSignature &
|
|
1800
1842
|
DeclareOpaqueTypeCloneSignature &
|
|
1801
1843
|
DeclareTypeAliasCloneSignature &
|
|
1802
1844
|
DeclareVariableCloneSignature &
|
|
@@ -1826,6 +1868,8 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
|
|
|
1826
1868
|
FunctionTypeAnnotationCloneSignature &
|
|
1827
1869
|
FunctionTypeParamCloneSignature &
|
|
1828
1870
|
GenericTypeAnnotationCloneSignature &
|
|
1871
|
+
HookDeclarationCloneSignature &
|
|
1872
|
+
HookTypeAnnotationCloneSignature &
|
|
1829
1873
|
IdentifierCloneSignature &
|
|
1830
1874
|
IfStatementCloneSignature &
|
|
1831
1875
|
ImportAttributeCloneSignature &
|
|
@@ -62,9 +62,11 @@ import type {
|
|
|
62
62
|
DeclareExportAllDeclaration,
|
|
63
63
|
DeclareExportDeclaration,
|
|
64
64
|
DeclareFunction,
|
|
65
|
+
DeclareHook,
|
|
65
66
|
DeclareInterface,
|
|
66
67
|
DeclareModule,
|
|
67
68
|
DeclareModuleExports,
|
|
69
|
+
DeclareNamespace,
|
|
68
70
|
DeclareOpaqueType,
|
|
69
71
|
DeclareTypeAlias,
|
|
70
72
|
DeclareVariable,
|
|
@@ -94,6 +96,8 @@ import type {
|
|
|
94
96
|
FunctionTypeAnnotation,
|
|
95
97
|
FunctionTypeParam,
|
|
96
98
|
GenericTypeAnnotation,
|
|
99
|
+
HookDeclaration,
|
|
100
|
+
HookTypeAnnotation,
|
|
97
101
|
Identifier,
|
|
98
102
|
IfStatement,
|
|
99
103
|
ImportAttribute,
|
|
@@ -237,9 +241,11 @@ import type {
|
|
|
237
241
|
DeclareExportAllDeclarationProps,
|
|
238
242
|
DeclareExportDeclarationProps,
|
|
239
243
|
DeclareFunctionProps,
|
|
244
|
+
DeclareHookProps,
|
|
240
245
|
DeclareInterfaceProps,
|
|
241
246
|
DeclareModuleProps,
|
|
242
247
|
DeclareModuleExportsProps,
|
|
248
|
+
DeclareNamespaceProps,
|
|
243
249
|
DeclareOpaqueTypeProps,
|
|
244
250
|
DeclareTypeAliasProps,
|
|
245
251
|
DeclareVariableProps,
|
|
@@ -269,6 +275,8 @@ import type {
|
|
|
269
275
|
FunctionTypeAnnotationProps,
|
|
270
276
|
FunctionTypeParamProps,
|
|
271
277
|
GenericTypeAnnotationProps,
|
|
278
|
+
HookDeclarationProps,
|
|
279
|
+
HookTypeAnnotationProps,
|
|
272
280
|
IdentifierProps,
|
|
273
281
|
IfStatementProps,
|
|
274
282
|
ImportAttributeProps,
|
|
@@ -532,6 +540,10 @@ type DeclareFunctionModifySignature = (
|
|
|
532
540
|
node: ?DeclareFunction,
|
|
533
541
|
newProps: Partial<DeclareFunctionProps>,
|
|
534
542
|
) => void;
|
|
543
|
+
type DeclareHookModifySignature = (
|
|
544
|
+
node: ?DeclareHook,
|
|
545
|
+
newProps: Partial<DeclareHookProps>,
|
|
546
|
+
) => void;
|
|
535
547
|
type DeclareInterfaceModifySignature = (
|
|
536
548
|
node: ?DeclareInterface,
|
|
537
549
|
newProps: Partial<DeclareInterfaceProps>,
|
|
@@ -544,6 +556,10 @@ type DeclareModuleExportsModifySignature = (
|
|
|
544
556
|
node: ?DeclareModuleExports,
|
|
545
557
|
newProps: Partial<DeclareModuleExportsProps>,
|
|
546
558
|
) => void;
|
|
559
|
+
type DeclareNamespaceModifySignature = (
|
|
560
|
+
node: ?DeclareNamespace,
|
|
561
|
+
newProps: Partial<DeclareNamespaceProps>,
|
|
562
|
+
) => void;
|
|
547
563
|
type DeclareOpaqueTypeModifySignature = (
|
|
548
564
|
node: ?DeclareOpaqueType,
|
|
549
565
|
newProps: Partial<DeclareOpaqueTypeProps>,
|
|
@@ -660,6 +676,14 @@ type GenericTypeAnnotationModifySignature = (
|
|
|
660
676
|
node: ?GenericTypeAnnotation,
|
|
661
677
|
newProps: Partial<GenericTypeAnnotationProps>,
|
|
662
678
|
) => void;
|
|
679
|
+
type HookDeclarationModifySignature = (
|
|
680
|
+
node: ?HookDeclaration,
|
|
681
|
+
newProps: Partial<HookDeclarationProps>,
|
|
682
|
+
) => void;
|
|
683
|
+
type HookTypeAnnotationModifySignature = (
|
|
684
|
+
node: ?HookTypeAnnotation,
|
|
685
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
686
|
+
) => void;
|
|
663
687
|
type IdentifierModifySignature = (
|
|
664
688
|
node: ?Identifier,
|
|
665
689
|
newProps: Partial<IdentifierProps>,
|
|
@@ -1104,9 +1128,11 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
|
|
|
1104
1128
|
DeclareExportAllDeclarationModifySignature &
|
|
1105
1129
|
DeclareExportDeclarationModifySignature &
|
|
1106
1130
|
DeclareFunctionModifySignature &
|
|
1131
|
+
DeclareHookModifySignature &
|
|
1107
1132
|
DeclareInterfaceModifySignature &
|
|
1108
1133
|
DeclareModuleModifySignature &
|
|
1109
1134
|
DeclareModuleExportsModifySignature &
|
|
1135
|
+
DeclareNamespaceModifySignature &
|
|
1110
1136
|
DeclareOpaqueTypeModifySignature &
|
|
1111
1137
|
DeclareTypeAliasModifySignature &
|
|
1112
1138
|
DeclareVariableModifySignature &
|
|
@@ -1136,6 +1162,8 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
|
|
|
1136
1162
|
FunctionTypeAnnotationModifySignature &
|
|
1137
1163
|
FunctionTypeParamModifySignature &
|
|
1138
1164
|
GenericTypeAnnotationModifySignature &
|
|
1165
|
+
HookDeclarationModifySignature &
|
|
1166
|
+
HookTypeAnnotationModifySignature &
|
|
1139
1167
|
IdentifierModifySignature &
|
|
1140
1168
|
IfStatementModifySignature &
|
|
1141
1169
|
ImportAttributeModifySignature &
|
|
@@ -60,9 +60,11 @@ import type {
|
|
|
60
60
|
DeclareExportAllDeclaration,
|
|
61
61
|
DeclareExportDeclaration,
|
|
62
62
|
DeclareFunction,
|
|
63
|
+
DeclareHook,
|
|
63
64
|
DeclareInterface,
|
|
64
65
|
DeclareModule,
|
|
65
66
|
DeclareModuleExports,
|
|
67
|
+
DeclareNamespace,
|
|
66
68
|
DeclareOpaqueType,
|
|
67
69
|
DeclareTypeAlias,
|
|
68
70
|
DeclareVariable,
|
|
@@ -92,6 +94,8 @@ import type {
|
|
|
92
94
|
FunctionTypeAnnotation,
|
|
93
95
|
FunctionTypeParam,
|
|
94
96
|
GenericTypeAnnotation,
|
|
97
|
+
HookDeclaration,
|
|
98
|
+
HookTypeAnnotation,
|
|
95
99
|
Identifier,
|
|
96
100
|
IfStatement,
|
|
97
101
|
ImportAttribute,
|
|
@@ -384,6 +388,11 @@ type DeclareFunctionReplaceSignature = (
|
|
|
384
388
|
nodeToReplaceWith: DetachedNode<DeclareFunction>,
|
|
385
389
|
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
386
390
|
) => void;
|
|
391
|
+
type DeclareHookReplaceSignature = (
|
|
392
|
+
target: DeclareHook,
|
|
393
|
+
nodeToReplaceWith: DetachedNode<DeclareHook>,
|
|
394
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
395
|
+
) => void;
|
|
387
396
|
type DeclareInterfaceReplaceSignature = (
|
|
388
397
|
target: DeclareInterface,
|
|
389
398
|
nodeToReplaceWith: DetachedNode<DeclareInterface>,
|
|
@@ -399,6 +408,11 @@ type DeclareModuleExportsReplaceSignature = (
|
|
|
399
408
|
nodeToReplaceWith: DetachedNode<DeclareModuleExports>,
|
|
400
409
|
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
401
410
|
) => void;
|
|
411
|
+
type DeclareNamespaceReplaceSignature = (
|
|
412
|
+
target: DeclareNamespace,
|
|
413
|
+
nodeToReplaceWith: DetachedNode<DeclareNamespace>,
|
|
414
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
415
|
+
) => void;
|
|
402
416
|
type DeclareOpaqueTypeReplaceSignature = (
|
|
403
417
|
target: DeclareOpaqueType,
|
|
404
418
|
nodeToReplaceWith: DetachedNode<DeclareOpaqueType>,
|
|
@@ -544,6 +558,16 @@ type GenericTypeAnnotationReplaceSignature = (
|
|
|
544
558
|
nodeToReplaceWith: DetachedNode<GenericTypeAnnotation>,
|
|
545
559
|
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
546
560
|
) => void;
|
|
561
|
+
type HookDeclarationReplaceSignature = (
|
|
562
|
+
target: HookDeclaration,
|
|
563
|
+
nodeToReplaceWith: DetachedNode<HookDeclaration>,
|
|
564
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
565
|
+
) => void;
|
|
566
|
+
type HookTypeAnnotationReplaceSignature = (
|
|
567
|
+
target: HookTypeAnnotation,
|
|
568
|
+
nodeToReplaceWith: DetachedNode<HookTypeAnnotation>,
|
|
569
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
570
|
+
) => void;
|
|
547
571
|
type IdentifierReplaceSignature = (
|
|
548
572
|
target: Identifier,
|
|
549
573
|
nodeToReplaceWith: DetachedNode<Identifier>,
|
|
@@ -1077,9 +1101,11 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
|
|
|
1077
1101
|
DeclareExportAllDeclarationReplaceSignature &
|
|
1078
1102
|
DeclareExportDeclarationReplaceSignature &
|
|
1079
1103
|
DeclareFunctionReplaceSignature &
|
|
1104
|
+
DeclareHookReplaceSignature &
|
|
1080
1105
|
DeclareInterfaceReplaceSignature &
|
|
1081
1106
|
DeclareModuleReplaceSignature &
|
|
1082
1107
|
DeclareModuleExportsReplaceSignature &
|
|
1108
|
+
DeclareNamespaceReplaceSignature &
|
|
1083
1109
|
DeclareOpaqueTypeReplaceSignature &
|
|
1084
1110
|
DeclareTypeAliasReplaceSignature &
|
|
1085
1111
|
DeclareVariableReplaceSignature &
|
|
@@ -1109,6 +1135,8 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
|
|
|
1109
1135
|
FunctionTypeAnnotationReplaceSignature &
|
|
1110
1136
|
FunctionTypeParamReplaceSignature &
|
|
1111
1137
|
GenericTypeAnnotationReplaceSignature &
|
|
1138
|
+
HookDeclarationReplaceSignature &
|
|
1139
|
+
HookTypeAnnotationReplaceSignature &
|
|
1112
1140
|
IdentifierReplaceSignature &
|
|
1113
1141
|
IfStatementReplaceSignature &
|
|
1114
1142
|
ImportAttributeReplaceSignature &
|
|
@@ -62,6 +62,7 @@ var _exportNames = {
|
|
|
62
62
|
DeclareInterface: true,
|
|
63
63
|
DeclareModule: true,
|
|
64
64
|
DeclareModuleExports: true,
|
|
65
|
+
DeclareNamespace: true,
|
|
65
66
|
DeclareOpaqueType: true,
|
|
66
67
|
DeclareTypeAlias: true,
|
|
67
68
|
DeclareVariable: true,
|
|
@@ -90,6 +91,8 @@ var _exportNames = {
|
|
|
90
91
|
FunctionTypeAnnotation: true,
|
|
91
92
|
FunctionTypeParam: true,
|
|
92
93
|
GenericTypeAnnotation: true,
|
|
94
|
+
HookDeclaration: true,
|
|
95
|
+
HookTypeAnnotation: true,
|
|
93
96
|
IfStatement: true,
|
|
94
97
|
ImportAttribute: true,
|
|
95
98
|
ImportDeclaration: true,
|
|
@@ -220,6 +223,7 @@ exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
|
|
220
223
|
exports.DeclareInterface = DeclareInterface;
|
|
221
224
|
exports.DeclareModule = DeclareModule;
|
|
222
225
|
exports.DeclareModuleExports = DeclareModuleExports;
|
|
226
|
+
exports.DeclareNamespace = DeclareNamespace;
|
|
223
227
|
exports.DeclareOpaqueType = DeclareOpaqueType;
|
|
224
228
|
exports.DeclareTypeAlias = DeclareTypeAlias;
|
|
225
229
|
exports.DeclareVariable = DeclareVariable;
|
|
@@ -249,6 +253,8 @@ exports.FunctionExpression = FunctionExpression;
|
|
|
249
253
|
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
|
250
254
|
exports.FunctionTypeParam = FunctionTypeParam;
|
|
251
255
|
exports.GenericTypeAnnotation = GenericTypeAnnotation;
|
|
256
|
+
exports.HookDeclaration = HookDeclaration;
|
|
257
|
+
exports.HookTypeAnnotation = HookTypeAnnotation;
|
|
252
258
|
exports.IfStatement = IfStatement;
|
|
253
259
|
exports.ImportAttribute = ImportAttribute;
|
|
254
260
|
exports.ImportDeclaration = ImportDeclaration;
|
|
@@ -713,8 +719,7 @@ function DeclareModule(props) {
|
|
|
713
719
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
714
720
|
type: 'DeclareModule',
|
|
715
721
|
id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
|
|
716
|
-
body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body)
|
|
717
|
-
kind: props.kind
|
|
722
|
+
body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body)
|
|
718
723
|
});
|
|
719
724
|
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
720
725
|
return node;
|
|
@@ -729,6 +734,16 @@ function DeclareModuleExports(props) {
|
|
|
729
734
|
return node;
|
|
730
735
|
}
|
|
731
736
|
|
|
737
|
+
function DeclareNamespace(props) {
|
|
738
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
739
|
+
type: 'DeclareNamespace',
|
|
740
|
+
id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
|
|
741
|
+
body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body)
|
|
742
|
+
});
|
|
743
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
744
|
+
return node;
|
|
745
|
+
}
|
|
746
|
+
|
|
732
747
|
function DeclareOpaqueType(props) {
|
|
733
748
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
734
749
|
type: 'DeclareOpaqueType',
|
|
@@ -1026,6 +1041,31 @@ function GenericTypeAnnotation(props) {
|
|
|
1026
1041
|
return node;
|
|
1027
1042
|
}
|
|
1028
1043
|
|
|
1044
|
+
function HookDeclaration(props) {
|
|
1045
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1046
|
+
type: 'HookDeclaration',
|
|
1047
|
+
id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
|
|
1048
|
+
params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
|
|
1049
|
+
body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
|
|
1050
|
+
typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
|
|
1051
|
+
returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType)
|
|
1052
|
+
});
|
|
1053
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1054
|
+
return node;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function HookTypeAnnotation(props) {
|
|
1058
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1059
|
+
type: 'HookTypeAnnotation',
|
|
1060
|
+
params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
|
|
1061
|
+
returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType),
|
|
1062
|
+
rest: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rest),
|
|
1063
|
+
typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters)
|
|
1064
|
+
});
|
|
1065
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1066
|
+
return node;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1029
1069
|
function IfStatement(props) {
|
|
1030
1070
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1031
1071
|
type: 'IfStatement',
|
|
@@ -1789,7 +1829,8 @@ function TypeCastExpression(props) {
|
|
|
1789
1829
|
function TypeofTypeAnnotation(props) {
|
|
1790
1830
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1791
1831
|
type: 'TypeofTypeAnnotation',
|
|
1792
|
-
argument: (0, _detachedNode.asDetachedNodeForCodeGen)(props.argument)
|
|
1832
|
+
argument: (0, _detachedNode.asDetachedNodeForCodeGen)(props.argument),
|
|
1833
|
+
typeArguments: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeArguments)
|
|
1793
1834
|
});
|
|
1794
1835
|
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1795
1836
|
return node;
|
|
@@ -60,6 +60,7 @@ import type {
|
|
|
60
60
|
DeclareInterface as DeclareInterfaceType,
|
|
61
61
|
DeclareModule as DeclareModuleType,
|
|
62
62
|
DeclareModuleExports as DeclareModuleExportsType,
|
|
63
|
+
DeclareNamespace as DeclareNamespaceType,
|
|
63
64
|
DeclareOpaqueType as DeclareOpaqueTypeType,
|
|
64
65
|
DeclareTypeAlias as DeclareTypeAliasType,
|
|
65
66
|
DeclareVariable as DeclareVariableType,
|
|
@@ -88,6 +89,8 @@ import type {
|
|
|
88
89
|
FunctionTypeAnnotation as FunctionTypeAnnotationType,
|
|
89
90
|
FunctionTypeParam as FunctionTypeParamType,
|
|
90
91
|
GenericTypeAnnotation as GenericTypeAnnotationType,
|
|
92
|
+
HookDeclaration as HookDeclarationType,
|
|
93
|
+
HookTypeAnnotation as HookTypeAnnotationType,
|
|
91
94
|
IfStatement as IfStatementType,
|
|
92
95
|
ImportAttribute as ImportAttributeType,
|
|
93
96
|
ImportDeclaration as ImportDeclarationType,
|
|
@@ -405,7 +408,6 @@ export type DeclareInterfaceProps = {
|
|
|
405
408
|
export type DeclareModuleProps = {
|
|
406
409
|
+id: MaybeDetachedNode<DeclareModuleType['id']>,
|
|
407
410
|
+body: MaybeDetachedNode<DeclareModuleType['body']>,
|
|
408
|
-
+kind: DeclareModuleType['kind'],
|
|
409
411
|
};
|
|
410
412
|
|
|
411
413
|
export type DeclareModuleExportsProps = {
|
|
@@ -414,6 +416,11 @@ export type DeclareModuleExportsProps = {
|
|
|
414
416
|
>,
|
|
415
417
|
};
|
|
416
418
|
|
|
419
|
+
export type DeclareNamespaceProps = {
|
|
420
|
+
+id: MaybeDetachedNode<DeclareNamespaceType['id']>,
|
|
421
|
+
+body: MaybeDetachedNode<DeclareNamespaceType['body']>,
|
|
422
|
+
};
|
|
423
|
+
|
|
417
424
|
export type DeclareOpaqueTypeProps = {
|
|
418
425
|
+id: MaybeDetachedNode<DeclareOpaqueTypeType['id']>,
|
|
419
426
|
+typeParameters?: ?MaybeDetachedNode<DeclareOpaqueTypeType['typeParameters']>,
|
|
@@ -593,6 +600,27 @@ export type GenericTypeAnnotationProps = {
|
|
|
593
600
|
>,
|
|
594
601
|
};
|
|
595
602
|
|
|
603
|
+
export type HookDeclarationProps = {
|
|
604
|
+
+id: MaybeDetachedNode<HookDeclarationType['id']>,
|
|
605
|
+
+params: $ReadOnlyArray<
|
|
606
|
+
MaybeDetachedNode<HookDeclarationType['params'][number]>,
|
|
607
|
+
>,
|
|
608
|
+
+body: MaybeDetachedNode<HookDeclarationType['body']>,
|
|
609
|
+
+typeParameters?: ?MaybeDetachedNode<HookDeclarationType['typeParameters']>,
|
|
610
|
+
+returnType?: ?MaybeDetachedNode<HookDeclarationType['returnType']>,
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
export type HookTypeAnnotationProps = {
|
|
614
|
+
+params: $ReadOnlyArray<
|
|
615
|
+
MaybeDetachedNode<HookTypeAnnotationType['params'][number]>,
|
|
616
|
+
>,
|
|
617
|
+
+returnType: MaybeDetachedNode<HookTypeAnnotationType['returnType']>,
|
|
618
|
+
+rest?: ?MaybeDetachedNode<HookTypeAnnotationType['rest']>,
|
|
619
|
+
+typeParameters?: ?MaybeDetachedNode<
|
|
620
|
+
HookTypeAnnotationType['typeParameters'],
|
|
621
|
+
>,
|
|
622
|
+
};
|
|
623
|
+
|
|
596
624
|
export type IfStatementProps = {
|
|
597
625
|
+test: MaybeDetachedNode<IfStatementType['test']>,
|
|
598
626
|
+consequent: MaybeDetachedNode<IfStatementType['consequent']>,
|
|
@@ -1024,6 +1052,9 @@ export type TypeCastExpressionProps = {
|
|
|
1024
1052
|
|
|
1025
1053
|
export type TypeofTypeAnnotationProps = {
|
|
1026
1054
|
+argument: MaybeDetachedNode<TypeofTypeAnnotationType['argument']>,
|
|
1055
|
+
+typeArguments?: ?MaybeDetachedNode<
|
|
1056
|
+
TypeofTypeAnnotationType['typeArguments'],
|
|
1057
|
+
>,
|
|
1027
1058
|
};
|
|
1028
1059
|
|
|
1029
1060
|
export type TypeOperatorProps = {
|
|
@@ -1576,7 +1607,6 @@ export function DeclareModule(props: {
|
|
|
1576
1607
|
type: 'DeclareModule',
|
|
1577
1608
|
id: asDetachedNodeForCodeGen(props.id),
|
|
1578
1609
|
body: asDetachedNodeForCodeGen(props.body),
|
|
1579
|
-
kind: props.kind,
|
|
1580
1610
|
});
|
|
1581
1611
|
setParentPointersInDirectChildren(node);
|
|
1582
1612
|
return node;
|
|
@@ -1594,6 +1624,19 @@ export function DeclareModuleExports(props: {
|
|
|
1594
1624
|
return node;
|
|
1595
1625
|
}
|
|
1596
1626
|
|
|
1627
|
+
export function DeclareNamespace(props: {
|
|
1628
|
+
...$ReadOnly<DeclareNamespaceProps>,
|
|
1629
|
+
+parent?: ESNode,
|
|
1630
|
+
}): DetachedNode<DeclareNamespaceType> {
|
|
1631
|
+
const node = detachedProps<DeclareNamespaceType>(props.parent, {
|
|
1632
|
+
type: 'DeclareNamespace',
|
|
1633
|
+
id: asDetachedNodeForCodeGen(props.id),
|
|
1634
|
+
body: asDetachedNodeForCodeGen(props.body),
|
|
1635
|
+
});
|
|
1636
|
+
setParentPointersInDirectChildren(node);
|
|
1637
|
+
return node;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1597
1640
|
export function DeclareOpaqueType(props: {
|
|
1598
1641
|
...$ReadOnly<DeclareOpaqueTypeProps>,
|
|
1599
1642
|
+parent?: ESNode,
|
|
@@ -1975,6 +2018,37 @@ export function GenericTypeAnnotation(props: {
|
|
|
1975
2018
|
return node;
|
|
1976
2019
|
}
|
|
1977
2020
|
|
|
2021
|
+
export function HookDeclaration(props: {
|
|
2022
|
+
...$ReadOnly<HookDeclarationProps>,
|
|
2023
|
+
+parent?: ESNode,
|
|
2024
|
+
}): DetachedNode<HookDeclarationType> {
|
|
2025
|
+
const node = detachedProps<HookDeclarationType>(props.parent, {
|
|
2026
|
+
type: 'HookDeclaration',
|
|
2027
|
+
id: asDetachedNodeForCodeGen(props.id),
|
|
2028
|
+
params: props.params.map(n => asDetachedNodeForCodeGen(n)),
|
|
2029
|
+
body: asDetachedNodeForCodeGen(props.body),
|
|
2030
|
+
typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
|
|
2031
|
+
returnType: asDetachedNodeForCodeGen(props.returnType),
|
|
2032
|
+
});
|
|
2033
|
+
setParentPointersInDirectChildren(node);
|
|
2034
|
+
return node;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
export function HookTypeAnnotation(props: {
|
|
2038
|
+
...$ReadOnly<HookTypeAnnotationProps>,
|
|
2039
|
+
+parent?: ESNode,
|
|
2040
|
+
}): DetachedNode<HookTypeAnnotationType> {
|
|
2041
|
+
const node = detachedProps<HookTypeAnnotationType>(props.parent, {
|
|
2042
|
+
type: 'HookTypeAnnotation',
|
|
2043
|
+
params: props.params.map(n => asDetachedNodeForCodeGen(n)),
|
|
2044
|
+
returnType: asDetachedNodeForCodeGen(props.returnType),
|
|
2045
|
+
rest: asDetachedNodeForCodeGen(props.rest),
|
|
2046
|
+
typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
|
|
2047
|
+
});
|
|
2048
|
+
setParentPointersInDirectChildren(node);
|
|
2049
|
+
return node;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
1978
2052
|
export function IfStatement(props: {
|
|
1979
2053
|
...$ReadOnly<IfStatementProps>,
|
|
1980
2054
|
+parent?: ESNode,
|
|
@@ -2971,6 +3045,7 @@ export function TypeofTypeAnnotation(props: {
|
|
|
2971
3045
|
const node = detachedProps<TypeofTypeAnnotationType>(props.parent, {
|
|
2972
3046
|
type: 'TypeofTypeAnnotation',
|
|
2973
3047
|
argument: asDetachedNodeForCodeGen(props.argument),
|
|
3048
|
+
typeArguments: asDetachedNodeForCodeGen(props.typeArguments),
|
|
2974
3049
|
});
|
|
2975
3050
|
setParentPointersInDirectChildren(node);
|
|
2976
3051
|
return node;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DeclareHook = DeclareHook;
|
|
7
|
+
|
|
8
|
+
var _detachedNode = require("../../detachedNode");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* @format
|
|
18
|
+
*/
|
|
19
|
+
function DeclareHook(props) {
|
|
20
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
21
|
+
type: 'DeclareHook',
|
|
22
|
+
id: (0, _detachedNode.detachedProps)(null, {
|
|
23
|
+
type: 'Identifier',
|
|
24
|
+
name: props.name,
|
|
25
|
+
typeAnnotation: (0, _detachedNode.detachedProps)(null, {
|
|
26
|
+
type: 'TypeAnnotation',
|
|
27
|
+
typeAnnotation: (0, _detachedNode.asDetachedNode)(props.functionType)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
DeclareHook as DeclareHookType,
|
|
13
|
+
ESNode,
|
|
14
|
+
FunctionTypeAnnotation as FunctionTypeAnnotationType,
|
|
15
|
+
} from 'hermes-estree';
|
|
16
|
+
import type {DetachedNode, MaybeDetachedNode} from '../../detachedNode';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
asDetachedNode,
|
|
20
|
+
detachedProps,
|
|
21
|
+
setParentPointersInDirectChildren,
|
|
22
|
+
} from '../../detachedNode';
|
|
23
|
+
|
|
24
|
+
// the type annotation is stored on the Identifier's typeAnnotation
|
|
25
|
+
// which is super awkward to work with and type - so we flatten the input
|
|
26
|
+
// and put it in the right spot after
|
|
27
|
+
export type DeclareHookProps = {
|
|
28
|
+
+name: string,
|
|
29
|
+
+functionType: MaybeDetachedNode<FunctionTypeAnnotationType>,
|
|
30
|
+
};
|
|
31
|
+
export function DeclareHook(props: {
|
|
32
|
+
...$ReadOnly<DeclareHookProps>,
|
|
33
|
+
+parent?: ESNode,
|
|
34
|
+
}): DetachedNode<DeclareHookType> {
|
|
35
|
+
const node = detachedProps<DeclareHookType>(props.parent, {
|
|
36
|
+
type: 'DeclareHook',
|
|
37
|
+
id: detachedProps(null, {
|
|
38
|
+
type: 'Identifier',
|
|
39
|
+
name: props.name,
|
|
40
|
+
typeAnnotation: detachedProps(null, {
|
|
41
|
+
type: 'TypeAnnotation',
|
|
42
|
+
typeAnnotation: asDetachedNode(props.functionType),
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
setParentPointersInDirectChildren(node);
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
@@ -58,4 +58,12 @@ Object.keys(_Property).forEach(function (key) {
|
|
|
58
58
|
if (key === "default" || key === "__esModule") return;
|
|
59
59
|
if (key in exports && exports[key] === _Property[key]) return;
|
|
60
60
|
exports[key] = _Property[key];
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var _DeclareHook = require("./special-case-node-types/DeclareHook");
|
|
64
|
+
|
|
65
|
+
Object.keys(_DeclareHook).forEach(function (key) {
|
|
66
|
+
if (key === "default" || key === "__esModule") return;
|
|
67
|
+
if (key in exports && exports[key] === _DeclareHook[key]) return;
|
|
68
|
+
exports[key] = _DeclareHook[key];
|
|
61
69
|
});
|
|
@@ -21,3 +21,4 @@ export * from './special-case-node-types/Literal';
|
|
|
21
21
|
export * from './special-case-node-types/ObjectTypeProperty';
|
|
22
22
|
export * from './special-case-node-types/misc';
|
|
23
23
|
export * from './special-case-node-types/Property';
|
|
24
|
+
export * from './special-case-node-types/DeclareHook';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-transform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
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
|
-
"hermes-estree": "0.
|
|
17
|
-
"hermes-parser": "0.
|
|
15
|
+
"hermes-eslint": "0.19.1",
|
|
16
|
+
"hermes-estree": "0.19.1",
|
|
17
|
+
"hermes-parser": "0.19.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"prettier": "^3.0.0 || ^2.7.1",
|
|
21
|
-
"prettier-plugin-hermes-parser": "0.
|
|
21
|
+
"prettier-plugin-hermes-parser": "0.19.1"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|