hermes-transform 0.18.2 → 0.19.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.
- package/dist/generated/TransformCloneSignatures.js.flow +33 -0
- package/dist/generated/TransformModifySignatures.js.flow +21 -0
- package/dist/generated/TransformReplaceSignatures.js.flow +21 -0
- package/dist/generated/node-types.js +31 -1
- package/dist/generated/node-types.js.flow +58 -0
- 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,6 +62,7 @@ import type {
|
|
|
62
62
|
DeclareExportAllDeclaration,
|
|
63
63
|
DeclareExportDeclaration,
|
|
64
64
|
DeclareFunction,
|
|
65
|
+
DeclareHook,
|
|
65
66
|
DeclareInterface,
|
|
66
67
|
DeclareModule,
|
|
67
68
|
DeclareModuleExports,
|
|
@@ -94,6 +95,8 @@ import type {
|
|
|
94
95
|
FunctionTypeAnnotation,
|
|
95
96
|
FunctionTypeParam,
|
|
96
97
|
GenericTypeAnnotation,
|
|
98
|
+
HookDeclaration,
|
|
99
|
+
HookTypeAnnotation,
|
|
97
100
|
Identifier,
|
|
98
101
|
IfStatement,
|
|
99
102
|
ImportAttribute,
|
|
@@ -237,6 +240,7 @@ import type {
|
|
|
237
240
|
DeclareExportAllDeclarationProps,
|
|
238
241
|
DeclareExportDeclarationProps,
|
|
239
242
|
DeclareFunctionProps,
|
|
243
|
+
DeclareHookProps,
|
|
240
244
|
DeclareInterfaceProps,
|
|
241
245
|
DeclareModuleProps,
|
|
242
246
|
DeclareModuleExportsProps,
|
|
@@ -269,6 +273,8 @@ import type {
|
|
|
269
273
|
FunctionTypeAnnotationProps,
|
|
270
274
|
FunctionTypeParamProps,
|
|
271
275
|
GenericTypeAnnotationProps,
|
|
276
|
+
HookDeclarationProps,
|
|
277
|
+
HookTypeAnnotationProps,
|
|
272
278
|
IdentifierProps,
|
|
273
279
|
IfStatementProps,
|
|
274
280
|
ImportAttributeProps,
|
|
@@ -693,6 +699,14 @@ type DeclareFunctionCloneSignature = ((
|
|
|
693
699
|
node: ?DeclareFunction,
|
|
694
700
|
newProps: Partial<DeclareFunctionProps>,
|
|
695
701
|
) => DetachedNode<DeclareFunction> | null);
|
|
702
|
+
type DeclareHookCloneSignature = ((
|
|
703
|
+
node: DeclareHook,
|
|
704
|
+
newProps: Partial<DeclareHookProps>,
|
|
705
|
+
) => DetachedNode<DeclareHook>) &
|
|
706
|
+
((
|
|
707
|
+
node: ?DeclareHook,
|
|
708
|
+
newProps: Partial<DeclareHookProps>,
|
|
709
|
+
) => DetachedNode<DeclareHook> | null);
|
|
696
710
|
type DeclareInterfaceCloneSignature = ((
|
|
697
711
|
node: DeclareInterface,
|
|
698
712
|
newProps: Partial<DeclareInterfaceProps>,
|
|
@@ -949,6 +963,22 @@ type GenericTypeAnnotationCloneSignature = ((
|
|
|
949
963
|
node: ?GenericTypeAnnotation,
|
|
950
964
|
newProps: Partial<GenericTypeAnnotationProps>,
|
|
951
965
|
) => DetachedNode<GenericTypeAnnotation> | null);
|
|
966
|
+
type HookDeclarationCloneSignature = ((
|
|
967
|
+
node: HookDeclaration,
|
|
968
|
+
newProps: Partial<HookDeclarationProps>,
|
|
969
|
+
) => DetachedNode<HookDeclaration>) &
|
|
970
|
+
((
|
|
971
|
+
node: ?HookDeclaration,
|
|
972
|
+
newProps: Partial<HookDeclarationProps>,
|
|
973
|
+
) => DetachedNode<HookDeclaration> | null);
|
|
974
|
+
type HookTypeAnnotationCloneSignature = ((
|
|
975
|
+
node: HookTypeAnnotation,
|
|
976
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
977
|
+
) => DetachedNode<HookTypeAnnotation>) &
|
|
978
|
+
((
|
|
979
|
+
node: ?HookTypeAnnotation,
|
|
980
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
981
|
+
) => DetachedNode<HookTypeAnnotation> | null);
|
|
952
982
|
type IdentifierCloneSignature = ((
|
|
953
983
|
node: Identifier,
|
|
954
984
|
newProps: Partial<IdentifierProps>,
|
|
@@ -1794,6 +1824,7 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
|
|
|
1794
1824
|
DeclareExportAllDeclarationCloneSignature &
|
|
1795
1825
|
DeclareExportDeclarationCloneSignature &
|
|
1796
1826
|
DeclareFunctionCloneSignature &
|
|
1827
|
+
DeclareHookCloneSignature &
|
|
1797
1828
|
DeclareInterfaceCloneSignature &
|
|
1798
1829
|
DeclareModuleCloneSignature &
|
|
1799
1830
|
DeclareModuleExportsCloneSignature &
|
|
@@ -1826,6 +1857,8 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
|
|
|
1826
1857
|
FunctionTypeAnnotationCloneSignature &
|
|
1827
1858
|
FunctionTypeParamCloneSignature &
|
|
1828
1859
|
GenericTypeAnnotationCloneSignature &
|
|
1860
|
+
HookDeclarationCloneSignature &
|
|
1861
|
+
HookTypeAnnotationCloneSignature &
|
|
1829
1862
|
IdentifierCloneSignature &
|
|
1830
1863
|
IfStatementCloneSignature &
|
|
1831
1864
|
ImportAttributeCloneSignature &
|
|
@@ -62,6 +62,7 @@ import type {
|
|
|
62
62
|
DeclareExportAllDeclaration,
|
|
63
63
|
DeclareExportDeclaration,
|
|
64
64
|
DeclareFunction,
|
|
65
|
+
DeclareHook,
|
|
65
66
|
DeclareInterface,
|
|
66
67
|
DeclareModule,
|
|
67
68
|
DeclareModuleExports,
|
|
@@ -94,6 +95,8 @@ import type {
|
|
|
94
95
|
FunctionTypeAnnotation,
|
|
95
96
|
FunctionTypeParam,
|
|
96
97
|
GenericTypeAnnotation,
|
|
98
|
+
HookDeclaration,
|
|
99
|
+
HookTypeAnnotation,
|
|
97
100
|
Identifier,
|
|
98
101
|
IfStatement,
|
|
99
102
|
ImportAttribute,
|
|
@@ -237,6 +240,7 @@ import type {
|
|
|
237
240
|
DeclareExportAllDeclarationProps,
|
|
238
241
|
DeclareExportDeclarationProps,
|
|
239
242
|
DeclareFunctionProps,
|
|
243
|
+
DeclareHookProps,
|
|
240
244
|
DeclareInterfaceProps,
|
|
241
245
|
DeclareModuleProps,
|
|
242
246
|
DeclareModuleExportsProps,
|
|
@@ -269,6 +273,8 @@ import type {
|
|
|
269
273
|
FunctionTypeAnnotationProps,
|
|
270
274
|
FunctionTypeParamProps,
|
|
271
275
|
GenericTypeAnnotationProps,
|
|
276
|
+
HookDeclarationProps,
|
|
277
|
+
HookTypeAnnotationProps,
|
|
272
278
|
IdentifierProps,
|
|
273
279
|
IfStatementProps,
|
|
274
280
|
ImportAttributeProps,
|
|
@@ -532,6 +538,10 @@ type DeclareFunctionModifySignature = (
|
|
|
532
538
|
node: ?DeclareFunction,
|
|
533
539
|
newProps: Partial<DeclareFunctionProps>,
|
|
534
540
|
) => void;
|
|
541
|
+
type DeclareHookModifySignature = (
|
|
542
|
+
node: ?DeclareHook,
|
|
543
|
+
newProps: Partial<DeclareHookProps>,
|
|
544
|
+
) => void;
|
|
535
545
|
type DeclareInterfaceModifySignature = (
|
|
536
546
|
node: ?DeclareInterface,
|
|
537
547
|
newProps: Partial<DeclareInterfaceProps>,
|
|
@@ -660,6 +670,14 @@ type GenericTypeAnnotationModifySignature = (
|
|
|
660
670
|
node: ?GenericTypeAnnotation,
|
|
661
671
|
newProps: Partial<GenericTypeAnnotationProps>,
|
|
662
672
|
) => void;
|
|
673
|
+
type HookDeclarationModifySignature = (
|
|
674
|
+
node: ?HookDeclaration,
|
|
675
|
+
newProps: Partial<HookDeclarationProps>,
|
|
676
|
+
) => void;
|
|
677
|
+
type HookTypeAnnotationModifySignature = (
|
|
678
|
+
node: ?HookTypeAnnotation,
|
|
679
|
+
newProps: Partial<HookTypeAnnotationProps>,
|
|
680
|
+
) => void;
|
|
663
681
|
type IdentifierModifySignature = (
|
|
664
682
|
node: ?Identifier,
|
|
665
683
|
newProps: Partial<IdentifierProps>,
|
|
@@ -1104,6 +1122,7 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
|
|
|
1104
1122
|
DeclareExportAllDeclarationModifySignature &
|
|
1105
1123
|
DeclareExportDeclarationModifySignature &
|
|
1106
1124
|
DeclareFunctionModifySignature &
|
|
1125
|
+
DeclareHookModifySignature &
|
|
1107
1126
|
DeclareInterfaceModifySignature &
|
|
1108
1127
|
DeclareModuleModifySignature &
|
|
1109
1128
|
DeclareModuleExportsModifySignature &
|
|
@@ -1136,6 +1155,8 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
|
|
|
1136
1155
|
FunctionTypeAnnotationModifySignature &
|
|
1137
1156
|
FunctionTypeParamModifySignature &
|
|
1138
1157
|
GenericTypeAnnotationModifySignature &
|
|
1158
|
+
HookDeclarationModifySignature &
|
|
1159
|
+
HookTypeAnnotationModifySignature &
|
|
1139
1160
|
IdentifierModifySignature &
|
|
1140
1161
|
IfStatementModifySignature &
|
|
1141
1162
|
ImportAttributeModifySignature &
|
|
@@ -60,6 +60,7 @@ import type {
|
|
|
60
60
|
DeclareExportAllDeclaration,
|
|
61
61
|
DeclareExportDeclaration,
|
|
62
62
|
DeclareFunction,
|
|
63
|
+
DeclareHook,
|
|
63
64
|
DeclareInterface,
|
|
64
65
|
DeclareModule,
|
|
65
66
|
DeclareModuleExports,
|
|
@@ -92,6 +93,8 @@ import type {
|
|
|
92
93
|
FunctionTypeAnnotation,
|
|
93
94
|
FunctionTypeParam,
|
|
94
95
|
GenericTypeAnnotation,
|
|
96
|
+
HookDeclaration,
|
|
97
|
+
HookTypeAnnotation,
|
|
95
98
|
Identifier,
|
|
96
99
|
IfStatement,
|
|
97
100
|
ImportAttribute,
|
|
@@ -384,6 +387,11 @@ type DeclareFunctionReplaceSignature = (
|
|
|
384
387
|
nodeToReplaceWith: DetachedNode<DeclareFunction>,
|
|
385
388
|
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
386
389
|
) => void;
|
|
390
|
+
type DeclareHookReplaceSignature = (
|
|
391
|
+
target: DeclareHook,
|
|
392
|
+
nodeToReplaceWith: DetachedNode<DeclareHook>,
|
|
393
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
394
|
+
) => void;
|
|
387
395
|
type DeclareInterfaceReplaceSignature = (
|
|
388
396
|
target: DeclareInterface,
|
|
389
397
|
nodeToReplaceWith: DetachedNode<DeclareInterface>,
|
|
@@ -544,6 +552,16 @@ type GenericTypeAnnotationReplaceSignature = (
|
|
|
544
552
|
nodeToReplaceWith: DetachedNode<GenericTypeAnnotation>,
|
|
545
553
|
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
546
554
|
) => void;
|
|
555
|
+
type HookDeclarationReplaceSignature = (
|
|
556
|
+
target: HookDeclaration,
|
|
557
|
+
nodeToReplaceWith: DetachedNode<HookDeclaration>,
|
|
558
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
559
|
+
) => void;
|
|
560
|
+
type HookTypeAnnotationReplaceSignature = (
|
|
561
|
+
target: HookTypeAnnotation,
|
|
562
|
+
nodeToReplaceWith: DetachedNode<HookTypeAnnotation>,
|
|
563
|
+
options?: $ReadOnly<{keepComments?: boolean}>,
|
|
564
|
+
) => void;
|
|
547
565
|
type IdentifierReplaceSignature = (
|
|
548
566
|
target: Identifier,
|
|
549
567
|
nodeToReplaceWith: DetachedNode<Identifier>,
|
|
@@ -1077,6 +1095,7 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
|
|
|
1077
1095
|
DeclareExportAllDeclarationReplaceSignature &
|
|
1078
1096
|
DeclareExportDeclarationReplaceSignature &
|
|
1079
1097
|
DeclareFunctionReplaceSignature &
|
|
1098
|
+
DeclareHookReplaceSignature &
|
|
1080
1099
|
DeclareInterfaceReplaceSignature &
|
|
1081
1100
|
DeclareModuleReplaceSignature &
|
|
1082
1101
|
DeclareModuleExportsReplaceSignature &
|
|
@@ -1109,6 +1128,8 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
|
|
|
1109
1128
|
FunctionTypeAnnotationReplaceSignature &
|
|
1110
1129
|
FunctionTypeParamReplaceSignature &
|
|
1111
1130
|
GenericTypeAnnotationReplaceSignature &
|
|
1131
|
+
HookDeclarationReplaceSignature &
|
|
1132
|
+
HookTypeAnnotationReplaceSignature &
|
|
1112
1133
|
IdentifierReplaceSignature &
|
|
1113
1134
|
IfStatementReplaceSignature &
|
|
1114
1135
|
ImportAttributeReplaceSignature &
|
|
@@ -90,6 +90,8 @@ var _exportNames = {
|
|
|
90
90
|
FunctionTypeAnnotation: true,
|
|
91
91
|
FunctionTypeParam: true,
|
|
92
92
|
GenericTypeAnnotation: true,
|
|
93
|
+
HookDeclaration: true,
|
|
94
|
+
HookTypeAnnotation: true,
|
|
93
95
|
IfStatement: true,
|
|
94
96
|
ImportAttribute: true,
|
|
95
97
|
ImportDeclaration: true,
|
|
@@ -249,6 +251,8 @@ exports.FunctionExpression = FunctionExpression;
|
|
|
249
251
|
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
|
250
252
|
exports.FunctionTypeParam = FunctionTypeParam;
|
|
251
253
|
exports.GenericTypeAnnotation = GenericTypeAnnotation;
|
|
254
|
+
exports.HookDeclaration = HookDeclaration;
|
|
255
|
+
exports.HookTypeAnnotation = HookTypeAnnotation;
|
|
252
256
|
exports.IfStatement = IfStatement;
|
|
253
257
|
exports.ImportAttribute = ImportAttribute;
|
|
254
258
|
exports.ImportDeclaration = ImportDeclaration;
|
|
@@ -1026,6 +1030,31 @@ function GenericTypeAnnotation(props) {
|
|
|
1026
1030
|
return node;
|
|
1027
1031
|
}
|
|
1028
1032
|
|
|
1033
|
+
function HookDeclaration(props) {
|
|
1034
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1035
|
+
type: 'HookDeclaration',
|
|
1036
|
+
id: (0, _detachedNode.asDetachedNodeForCodeGen)(props.id),
|
|
1037
|
+
params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
|
|
1038
|
+
body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
|
|
1039
|
+
typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
|
|
1040
|
+
returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType)
|
|
1041
|
+
});
|
|
1042
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1043
|
+
return node;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function HookTypeAnnotation(props) {
|
|
1047
|
+
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1048
|
+
type: 'HookTypeAnnotation',
|
|
1049
|
+
params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
|
|
1050
|
+
returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType),
|
|
1051
|
+
rest: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rest),
|
|
1052
|
+
typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters)
|
|
1053
|
+
});
|
|
1054
|
+
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1055
|
+
return node;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1029
1058
|
function IfStatement(props) {
|
|
1030
1059
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1031
1060
|
type: 'IfStatement',
|
|
@@ -1789,7 +1818,8 @@ function TypeCastExpression(props) {
|
|
|
1789
1818
|
function TypeofTypeAnnotation(props) {
|
|
1790
1819
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
1791
1820
|
type: 'TypeofTypeAnnotation',
|
|
1792
|
-
argument: (0, _detachedNode.asDetachedNodeForCodeGen)(props.argument)
|
|
1821
|
+
argument: (0, _detachedNode.asDetachedNodeForCodeGen)(props.argument),
|
|
1822
|
+
typeArguments: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeArguments)
|
|
1793
1823
|
});
|
|
1794
1824
|
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
1795
1825
|
return node;
|
|
@@ -88,6 +88,8 @@ import type {
|
|
|
88
88
|
FunctionTypeAnnotation as FunctionTypeAnnotationType,
|
|
89
89
|
FunctionTypeParam as FunctionTypeParamType,
|
|
90
90
|
GenericTypeAnnotation as GenericTypeAnnotationType,
|
|
91
|
+
HookDeclaration as HookDeclarationType,
|
|
92
|
+
HookTypeAnnotation as HookTypeAnnotationType,
|
|
91
93
|
IfStatement as IfStatementType,
|
|
92
94
|
ImportAttribute as ImportAttributeType,
|
|
93
95
|
ImportDeclaration as ImportDeclarationType,
|
|
@@ -593,6 +595,27 @@ export type GenericTypeAnnotationProps = {
|
|
|
593
595
|
>,
|
|
594
596
|
};
|
|
595
597
|
|
|
598
|
+
export type HookDeclarationProps = {
|
|
599
|
+
+id: MaybeDetachedNode<HookDeclarationType['id']>,
|
|
600
|
+
+params: $ReadOnlyArray<
|
|
601
|
+
MaybeDetachedNode<HookDeclarationType['params'][number]>,
|
|
602
|
+
>,
|
|
603
|
+
+body: MaybeDetachedNode<HookDeclarationType['body']>,
|
|
604
|
+
+typeParameters?: ?MaybeDetachedNode<HookDeclarationType['typeParameters']>,
|
|
605
|
+
+returnType?: ?MaybeDetachedNode<HookDeclarationType['returnType']>,
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export type HookTypeAnnotationProps = {
|
|
609
|
+
+params: $ReadOnlyArray<
|
|
610
|
+
MaybeDetachedNode<HookTypeAnnotationType['params'][number]>,
|
|
611
|
+
>,
|
|
612
|
+
+returnType: MaybeDetachedNode<HookTypeAnnotationType['returnType']>,
|
|
613
|
+
+rest?: ?MaybeDetachedNode<HookTypeAnnotationType['rest']>,
|
|
614
|
+
+typeParameters?: ?MaybeDetachedNode<
|
|
615
|
+
HookTypeAnnotationType['typeParameters'],
|
|
616
|
+
>,
|
|
617
|
+
};
|
|
618
|
+
|
|
596
619
|
export type IfStatementProps = {
|
|
597
620
|
+test: MaybeDetachedNode<IfStatementType['test']>,
|
|
598
621
|
+consequent: MaybeDetachedNode<IfStatementType['consequent']>,
|
|
@@ -1024,6 +1047,9 @@ export type TypeCastExpressionProps = {
|
|
|
1024
1047
|
|
|
1025
1048
|
export type TypeofTypeAnnotationProps = {
|
|
1026
1049
|
+argument: MaybeDetachedNode<TypeofTypeAnnotationType['argument']>,
|
|
1050
|
+
+typeArguments?: ?MaybeDetachedNode<
|
|
1051
|
+
TypeofTypeAnnotationType['typeArguments'],
|
|
1052
|
+
>,
|
|
1027
1053
|
};
|
|
1028
1054
|
|
|
1029
1055
|
export type TypeOperatorProps = {
|
|
@@ -1975,6 +2001,37 @@ export function GenericTypeAnnotation(props: {
|
|
|
1975
2001
|
return node;
|
|
1976
2002
|
}
|
|
1977
2003
|
|
|
2004
|
+
export function HookDeclaration(props: {
|
|
2005
|
+
...$ReadOnly<HookDeclarationProps>,
|
|
2006
|
+
+parent?: ESNode,
|
|
2007
|
+
}): DetachedNode<HookDeclarationType> {
|
|
2008
|
+
const node = detachedProps<HookDeclarationType>(props.parent, {
|
|
2009
|
+
type: 'HookDeclaration',
|
|
2010
|
+
id: asDetachedNodeForCodeGen(props.id),
|
|
2011
|
+
params: props.params.map(n => asDetachedNodeForCodeGen(n)),
|
|
2012
|
+
body: asDetachedNodeForCodeGen(props.body),
|
|
2013
|
+
typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
|
|
2014
|
+
returnType: asDetachedNodeForCodeGen(props.returnType),
|
|
2015
|
+
});
|
|
2016
|
+
setParentPointersInDirectChildren(node);
|
|
2017
|
+
return node;
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
export function HookTypeAnnotation(props: {
|
|
2021
|
+
...$ReadOnly<HookTypeAnnotationProps>,
|
|
2022
|
+
+parent?: ESNode,
|
|
2023
|
+
}): DetachedNode<HookTypeAnnotationType> {
|
|
2024
|
+
const node = detachedProps<HookTypeAnnotationType>(props.parent, {
|
|
2025
|
+
type: 'HookTypeAnnotation',
|
|
2026
|
+
params: props.params.map(n => asDetachedNodeForCodeGen(n)),
|
|
2027
|
+
returnType: asDetachedNodeForCodeGen(props.returnType),
|
|
2028
|
+
rest: asDetachedNodeForCodeGen(props.rest),
|
|
2029
|
+
typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
|
|
2030
|
+
});
|
|
2031
|
+
setParentPointersInDirectChildren(node);
|
|
2032
|
+
return node;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
1978
2035
|
export function IfStatement(props: {
|
|
1979
2036
|
...$ReadOnly<IfStatementProps>,
|
|
1980
2037
|
+parent?: ESNode,
|
|
@@ -2971,6 +3028,7 @@ export function TypeofTypeAnnotation(props: {
|
|
|
2971
3028
|
const node = detachedProps<TypeofTypeAnnotationType>(props.parent, {
|
|
2972
3029
|
type: 'TypeofTypeAnnotation',
|
|
2973
3030
|
argument: asDetachedNodeForCodeGen(props.argument),
|
|
3031
|
+
typeArguments: asDetachedNodeForCodeGen(props.typeArguments),
|
|
2974
3032
|
});
|
|
2975
3033
|
setParentPointersInDirectChildren(node);
|
|
2976
3034
|
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.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
|
-
"hermes-estree": "0.
|
|
17
|
-
"hermes-parser": "0.
|
|
15
|
+
"hermes-eslint": "0.19.0",
|
|
16
|
+
"hermes-estree": "0.19.0",
|
|
17
|
+
"hermes-parser": "0.19.0"
|
|
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.0"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|