hermes-transform 0.28.0 → 0.29.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.
Files changed (51) hide show
  1. package/dist/detachedNode.js +1 -0
  2. package/dist/detachedNode.js.flow +1 -0
  3. package/dist/generated/node-types.js +1 -12
  4. package/dist/generated/node-types.js.flow +2 -19
  5. package/dist/generated/special-case-node-types/misc.js +11 -0
  6. package/dist/generated/special-case-node-types/misc.js.flow +18 -0
  7. package/dist/src/detachedNode.js +178 -0
  8. package/dist/src/generated/node-types.js +2212 -0
  9. package/dist/src/generated/special-case-node-types/Comment.js +36 -0
  10. package/dist/src/generated/special-case-node-types/DeclareExportDeclaration.js +58 -0
  11. package/dist/src/generated/special-case-node-types/DeclareHook.js +33 -0
  12. package/dist/src/generated/special-case-node-types/ExportNamedDeclaration.js +44 -0
  13. package/dist/src/generated/special-case-node-types/Literal.js +97 -0
  14. package/dist/src/generated/special-case-node-types/ObjectTypeProperty.js +74 -0
  15. package/dist/src/generated/special-case-node-types/Property.js +136 -0
  16. package/dist/src/generated/special-case-node-types/misc.js +158 -0
  17. package/dist/src/generated/special-case-node-types.js +69 -0
  18. package/dist/src/index.js +53 -0
  19. package/dist/src/transform/Errors.js +43 -0
  20. package/dist/src/transform/MutationContext.js +81 -0
  21. package/dist/src/transform/TransformContext.js +213 -0
  22. package/dist/src/transform/comments/comments.js +308 -0
  23. package/dist/src/transform/comments/prettier/common/util.js +364 -0
  24. package/dist/src/transform/comments/prettier/language-js/comments.js +788 -0
  25. package/dist/src/transform/comments/prettier/language-js/loc.js +42 -0
  26. package/dist/src/transform/comments/prettier/language-js/printer-estree.js +32 -0
  27. package/dist/src/transform/comments/prettier/language-js/utils.js +119 -0
  28. package/dist/src/transform/comments/prettier/main/comments.js +440 -0
  29. package/dist/src/transform/comments/prettier/utils/get-last.js +13 -0
  30. package/dist/src/transform/mutations/AddComments.js +43 -0
  31. package/dist/src/transform/mutations/CloneCommentsTo.js +31 -0
  32. package/dist/src/transform/mutations/InsertStatement.js +91 -0
  33. package/dist/src/transform/mutations/ModifyNodeInPlace.js +59 -0
  34. package/dist/src/transform/mutations/RemoveComment.js +78 -0
  35. package/dist/src/transform/mutations/RemoveNode.js +205 -0
  36. package/dist/src/transform/mutations/RemoveStatement.js +59 -0
  37. package/dist/src/transform/mutations/ReplaceNode.js +92 -0
  38. package/dist/src/transform/mutations/ReplaceStatementWithMany.js +79 -0
  39. package/dist/src/transform/mutations/utils/getStatementParent.js +143 -0
  40. package/dist/src/transform/mutations/utils/isValidModuleDeclarationParent.js +43 -0
  41. package/dist/src/transform/parse.js +56 -0
  42. package/dist/src/transform/print.js +134 -0
  43. package/dist/src/transform/transform.js +36 -0
  44. package/dist/src/transform/transformAST.js +134 -0
  45. package/dist/src/traverse/NodeEventGenerator.js +353 -0
  46. package/dist/src/traverse/SafeEmitter.js +52 -0
  47. package/dist/src/traverse/esquery.js +37 -0
  48. package/dist/src/traverse/traverse.js +150 -0
  49. package/dist/transform/comments/prettier/language-js/comments.js +29 -1
  50. package/dist/transform/mutations/utils/getStatementParent.js.flow +7 -5
  51. package/package.json +5 -5
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BlockComment = BlockComment;
7
+ exports.LineComment = LineComment;
8
+
9
+ var _detachedNode = require("../../detachedNode");
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ * @format
19
+ */
20
+ function LineComment(props) {
21
+ // $FlowExpectedError[prop-missing]
22
+ // $FlowExpectedError[incompatible-return]
23
+ return (0, _detachedNode.detachedProps)(undefined, {
24
+ type: 'Line',
25
+ value: props.value
26
+ });
27
+ }
28
+
29
+ function BlockComment(props) {
30
+ // $FlowExpectedError[prop-missing]
31
+ // $FlowExpectedError[incompatible-return]
32
+ return (0, _detachedNode.detachedProps)(undefined, {
33
+ type: 'Block',
34
+ value: props.value
35
+ });
36
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DeclareExportDeclarationNamedWithDeclaration = DeclareExportDeclarationNamedWithDeclaration;
7
+ exports.DeclareExportDeclarationNamedWithSpecifiers = DeclareExportDeclarationNamedWithSpecifiers;
8
+ exports.DeclareExportDefaultDeclaration = DeclareExportDefaultDeclaration;
9
+
10
+ var _detachedNode = require("../../detachedNode");
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ *
19
+ * @format
20
+ */
21
+ function DeclareExportDefaultDeclaration(props) {
22
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
23
+ type: 'DeclareExportDeclaration',
24
+ // $FlowFixMe[incompatible-call]
25
+ declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
26
+ specifiers: [],
27
+ source: null,
28
+ default: true
29
+ });
30
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
31
+ return node;
32
+ }
33
+
34
+ function DeclareExportDeclarationNamedWithDeclaration(props) {
35
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
36
+ type: 'DeclareExportDeclaration',
37
+ // $FlowFixMe[incompatible-call]
38
+ declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
39
+ specifiers: [],
40
+ source: null,
41
+ default: false
42
+ });
43
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
44
+ return node;
45
+ }
46
+
47
+ function DeclareExportDeclarationNamedWithSpecifiers(props) {
48
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
49
+ type: 'DeclareExportDeclaration',
50
+ declaration: null,
51
+ specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
52
+ // $FlowFixMe[incompatible-call]
53
+ source: (0, _detachedNode.asDetachedNode)(props.source),
54
+ default: false
55
+ });
56
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
57
+ return node;
58
+ }
@@ -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,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ExportNamedDeclarationWithDeclaration = ExportNamedDeclarationWithDeclaration;
7
+ exports.ExportNamedDeclarationWithSpecifiers = ExportNamedDeclarationWithSpecifiers;
8
+
9
+ var _detachedNode = require("../../detachedNode");
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ * @format
19
+ */
20
+ function ExportNamedDeclarationWithDeclaration(props) {
21
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
22
+ type: 'ExportNamedDeclaration',
23
+ // $FlowFixMe[incompatible-call]
24
+ declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
25
+ specifiers: [],
26
+ source: null,
27
+ exportKind: props.exportKind
28
+ });
29
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
30
+ return node;
31
+ }
32
+
33
+ function ExportNamedDeclarationWithSpecifiers(props) {
34
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
35
+ type: 'ExportNamedDeclaration',
36
+ declaration: null,
37
+ specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
38
+ // $FlowFixMe[incompatible-call]
39
+ source: (0, _detachedNode.asDetachedNode)(props.source),
40
+ exportKind: props.exportKind
41
+ });
42
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
43
+ return node;
44
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BigIntLiteral = BigIntLiteral;
7
+ exports.BooleanLiteral = BooleanLiteral;
8
+ exports.NullLiteral = NullLiteral;
9
+ exports.NumericLiteral = NumericLiteral;
10
+ exports.RegExpLiteral = RegExpLiteral;
11
+ exports.StringLiteral = StringLiteral;
12
+
13
+ var _detachedNode = require("../../detachedNode");
14
+
15
+ /**
16
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
17
+ *
18
+ * This source code is licensed under the MIT license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ *
21
+ *
22
+ * @format
23
+ */
24
+ function BigIntLiteral(props) {
25
+ var _props$raw;
26
+
27
+ return (0, _detachedNode.detachedProps)(props.parent, {
28
+ type: 'Literal',
29
+ value: props.value,
30
+ raw: (_props$raw = props.raw) != null ? _props$raw : `${props.value}n`,
31
+ bigint: `${props.value}`
32
+ });
33
+ }
34
+
35
+ function BooleanLiteral(props) {
36
+ return (0, _detachedNode.detachedProps)(props.parent, {
37
+ type: 'Literal',
38
+ raw: props.value ? 'true' : 'false',
39
+ value: props.value
40
+ });
41
+ }
42
+
43
+ function NumericLiteral(props) {
44
+ var _props$raw2;
45
+
46
+ return (0, _detachedNode.detachedProps)(props.parent, {
47
+ type: 'Literal',
48
+ value: props.value,
49
+ raw: (_props$raw2 = props.raw) != null ? _props$raw2 : `${props.value}`
50
+ });
51
+ }
52
+
53
+ function NullLiteral(props = { ...null
54
+ }) {
55
+ return (0, _detachedNode.detachedProps)(props.parent, {
56
+ type: 'Literal',
57
+ value: null,
58
+ raw: 'null'
59
+ });
60
+ } // pattern/flags are on a subobject in the estree spec, but are flat on the hermes types
61
+ // also the value is supposed to be a RegExp instance
62
+
63
+
64
+ function RegExpLiteral(props) {
65
+ const value = new RegExp(props.pattern, props.flags);
66
+ return (0, _detachedNode.detachedProps)(props.parent, {
67
+ type: 'Literal',
68
+ value,
69
+ raw: value.toString(),
70
+ regex: {
71
+ pattern: props.pattern,
72
+ flags: props.flags
73
+ }
74
+ });
75
+ }
76
+
77
+ function StringLiteral(props) {
78
+ const hasSingleQuote = props.value.includes('"');
79
+ const hasDoubleQuote = props.value.includes("'");
80
+ let raw = props.raw;
81
+
82
+ if (raw == null) {
83
+ if (hasSingleQuote && hasDoubleQuote) {
84
+ raw = `'${props.value.replace(/'/g, "\\'")}'`;
85
+ } else if (hasSingleQuote) {
86
+ raw = `"${props.value}"`;
87
+ } else {
88
+ raw = `'${props.value}'`;
89
+ }
90
+ }
91
+
92
+ return (0, _detachedNode.detachedProps)(props.parent, {
93
+ type: 'Literal',
94
+ raw,
95
+ value: props.value
96
+ });
97
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ObjectTypeAccessorSignature = ObjectTypeAccessorSignature;
7
+ exports.ObjectTypeMethodSignature = ObjectTypeMethodSignature;
8
+ exports.ObjectTypePropertySignature = ObjectTypePropertySignature;
9
+
10
+ var _detachedNode = require("../../detachedNode");
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ *
19
+ * @format
20
+ */
21
+ function ObjectTypeMethodSignature(props) {
22
+ var _props$proto, _props$static;
23
+
24
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
25
+ type: 'ObjectTypeProperty',
26
+ key: (0, _detachedNode.asDetachedNode)(props.key),
27
+ kind: 'init',
28
+ method: true,
29
+ optional: false,
30
+ proto: (_props$proto = props.proto) != null ? _props$proto : false,
31
+ static: (_props$static = props.static) != null ? _props$static : false,
32
+ value: (0, _detachedNode.asDetachedNode)(props.value),
33
+ variance: null
34
+ });
35
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
36
+ return node;
37
+ }
38
+
39
+ function ObjectTypePropertySignature(props) {
40
+ var _props$proto2, _props$static2;
41
+
42
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
43
+ type: 'ObjectTypeProperty',
44
+ key: (0, _detachedNode.asDetachedNode)(props.key),
45
+ kind: 'init',
46
+ method: false,
47
+ optional: props.optional,
48
+ proto: (_props$proto2 = props.proto) != null ? _props$proto2 : false,
49
+ static: (_props$static2 = props.static) != null ? _props$static2 : false,
50
+ value: (0, _detachedNode.asDetachedNode)(props.value),
51
+ // $FlowFixMe[incompatible-call]
52
+ variance: (0, _detachedNode.asDetachedNode)(props.variance)
53
+ });
54
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
55
+ return node;
56
+ }
57
+
58
+ function ObjectTypeAccessorSignature(props) {
59
+ var _props$proto3, _props$static3;
60
+
61
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
62
+ type: 'ObjectTypeProperty',
63
+ key: (0, _detachedNode.asDetachedNode)(props.key),
64
+ kind: props.kind,
65
+ method: false,
66
+ optional: false,
67
+ proto: (_props$proto3 = props.proto) != null ? _props$proto3 : false,
68
+ static: (_props$static3 = props.static) != null ? _props$static3 : false,
69
+ value: (0, _detachedNode.asDetachedNode)(props.value),
70
+ variance: null
71
+ });
72
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
73
+ return node;
74
+ }
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DestructuringObjectProperty = DestructuringObjectProperty;
7
+ exports.DestructuringObjectPropertyWithComputedName = DestructuringObjectPropertyWithComputedName;
8
+ exports.DestructuringObjectPropertyWithNonShorthandStaticName = DestructuringObjectPropertyWithNonShorthandStaticName;
9
+ exports.DestructuringObjectPropertyWithShorthandStaticName = DestructuringObjectPropertyWithShorthandStaticName;
10
+ exports.ObjectProperty = ObjectProperty;
11
+ exports.ObjectPropertyWithComputedName = ObjectPropertyWithComputedName;
12
+ exports.ObjectPropertyWithNonShorthandStaticName = ObjectPropertyWithNonShorthandStaticName;
13
+ exports.ObjectPropertyWithShorthandStaticName = ObjectPropertyWithShorthandStaticName;
14
+
15
+ var _detachedNode = require("../../detachedNode");
16
+
17
+ /**
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ *
23
+ *
24
+ * @format
25
+ */
26
+ function DestructuringObjectProperty(props) {
27
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
28
+ type: 'Property',
29
+ kind: 'init',
30
+ method: false,
31
+ key: (0, _detachedNode.asDetachedNode)(props.key),
32
+ value: (0, _detachedNode.asDetachedNode)(props.value),
33
+ computed: props.computed,
34
+ shorthand: props.shorthand
35
+ });
36
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
37
+ return node;
38
+ }
39
+
40
+ function DestructuringObjectPropertyWithNonShorthandStaticName(props) {
41
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
42
+ type: 'Property',
43
+ kind: 'init',
44
+ method: false,
45
+ key: (0, _detachedNode.asDetachedNode)(props.key),
46
+ value: (0, _detachedNode.asDetachedNode)(props.value),
47
+ computed: false,
48
+ shorthand: false
49
+ });
50
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
51
+ return node;
52
+ }
53
+
54
+ function DestructuringObjectPropertyWithShorthandStaticName(props) {
55
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
56
+ type: 'Property',
57
+ kind: 'init',
58
+ method: false,
59
+ key: (0, _detachedNode.asDetachedNode)(props.key),
60
+ value: (0, _detachedNode.asDetachedNode)(props.value),
61
+ computed: false,
62
+ shorthand: true
63
+ });
64
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
65
+ return node;
66
+ }
67
+
68
+ function DestructuringObjectPropertyWithComputedName(props) {
69
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
70
+ type: 'Property',
71
+ kind: 'init',
72
+ method: false,
73
+ key: (0, _detachedNode.asDetachedNode)(props.key),
74
+ value: (0, _detachedNode.asDetachedNode)(props.value),
75
+ computed: true,
76
+ shorthand: false
77
+ });
78
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
79
+ return node;
80
+ }
81
+
82
+ function ObjectProperty(props) {
83
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
84
+ type: 'Property',
85
+ key: (0, _detachedNode.asDetachedNode)(props.key),
86
+ kind: props.kind,
87
+ value: (0, _detachedNode.asDetachedNode)(props.value),
88
+ computed: props.computed,
89
+ method: props.method,
90
+ shorthand: props.shorthand
91
+ });
92
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
93
+ return node;
94
+ }
95
+
96
+ function ObjectPropertyWithNonShorthandStaticName(props) {
97
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
98
+ type: 'Property',
99
+ key: (0, _detachedNode.asDetachedNode)(props.key),
100
+ kind: props.kind,
101
+ value: (0, _detachedNode.asDetachedNode)(props.value),
102
+ computed: false,
103
+ method: props.method,
104
+ shorthand: false
105
+ });
106
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
107
+ return node;
108
+ }
109
+
110
+ function ObjectPropertyWithShorthandStaticName(props) {
111
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
112
+ type: 'Property',
113
+ key: (0, _detachedNode.asDetachedNode)(props.key),
114
+ kind: 'init',
115
+ value: (0, _detachedNode.asDetachedNode)(props.value),
116
+ computed: false,
117
+ method: false,
118
+ shorthand: true
119
+ });
120
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
121
+ return node;
122
+ }
123
+
124
+ function ObjectPropertyWithComputedName(props) {
125
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
126
+ type: 'Property',
127
+ key: (0, _detachedNode.asDetachedNode)(props.key),
128
+ kind: props.kind,
129
+ value: (0, _detachedNode.asDetachedNode)(props.value),
130
+ computed: true,
131
+ method: props.method,
132
+ shorthand: false
133
+ });
134
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
135
+ return node;
136
+ }
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ArrowFunctionExpression = ArrowFunctionExpression;
7
+ exports.BlockStatement = BlockStatement;
8
+ exports.ClassDeclaration = ClassDeclaration;
9
+ exports.DeclareFunction = DeclareFunction;
10
+ exports.Identifier = Identifier;
11
+ exports.MemberExpression = MemberExpression;
12
+ exports.Program = Program;
13
+ exports.TemplateElement = TemplateElement;
14
+
15
+ var _detachedNode = require("../../detachedNode");
16
+
17
+ /**
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ *
23
+ *
24
+ * @format
25
+ */
26
+ function ArrowFunctionExpression(props) {
27
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
28
+ type: 'ArrowFunctionExpression',
29
+ id: null,
30
+ // $FlowExpectedError[incompatible-use]
31
+ expression: props.body.type !== 'BlockStatement',
32
+ params: props.params.map(n => (0, _detachedNode.asDetachedNode)(n)),
33
+ body: (0, _detachedNode.asDetachedNode)(props.body),
34
+ // $FlowFixMe[incompatible-call]
35
+ typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
36
+ // $FlowFixMe[incompatible-call]
37
+ returnType: (0, _detachedNode.asDetachedNode)(props.returnType),
38
+ // $FlowFixMe[incompatible-call]
39
+ predicate: (0, _detachedNode.asDetachedNode)(props.predicate),
40
+ async: props.async
41
+ });
42
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
43
+ return node;
44
+ }
45
+
46
+ function ClassDeclaration(props) {
47
+ var _props$decorators, _props$implements;
48
+
49
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
50
+ type: 'ClassDeclaration',
51
+ // $FlowFixMe[incompatible-call]
52
+ id: (0, _detachedNode.asDetachedNode)(props.id),
53
+ // $FlowFixMe[incompatible-call]
54
+ typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
55
+ // $FlowFixMe[incompatible-call]
56
+ superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
57
+ // $FlowFixMe[incompatible-call]
58
+ superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
59
+ decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
60
+ implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
61
+ body: (0, _detachedNode.asDetachedNode)(props.body)
62
+ });
63
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
64
+ return node;
65
+ } // raw/cooked are on a subobject in the estree spec, but are flat on the hermes types
66
+
67
+
68
+ function TemplateElement(props) {
69
+ return (0, _detachedNode.detachedProps)(props.parent, {
70
+ type: 'TemplateElement',
71
+ tail: props.tail,
72
+ value: {
73
+ cooked: props.cooked,
74
+ raw: props.raw
75
+ }
76
+ });
77
+ } // Identifier has a bunch of stuff that usually you don't want to provide - so we have
78
+ // this manual def to allow us to default some values
79
+
80
+
81
+ function Identifier(props) {
82
+ var _props$optional;
83
+
84
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
85
+ type: 'Identifier',
86
+ name: props.name,
87
+ optional: (_props$optional = props.optional) != null ? _props$optional : false,
88
+ // $FlowFixMe[incompatible-call]
89
+ typeAnnotation: (0, _detachedNode.asDetachedNode)(props.typeAnnotation)
90
+ });
91
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
92
+ return node;
93
+ } // Program has a bunch of stuff that usually you don't want to provide - so we have
94
+ // this manual def to allow us to default some values
95
+
96
+
97
+ function Program(props) {
98
+ var _props$sourceType, _props$tokens, _props$comments;
99
+
100
+ return (0, _detachedNode.detachedProps)(null, {
101
+ type: 'Program',
102
+ sourceType: (_props$sourceType = props.sourceType) != null ? _props$sourceType : 'module',
103
+ body: props.body.map(n => (0, _detachedNode.asDetachedNode)(n)),
104
+ tokens: (_props$tokens = props.tokens) != null ? _props$tokens : [],
105
+ comments: (_props$comments = props.comments) != null ? _props$comments : [],
106
+ interpreter: props.interpreter != null ? // $FlowFixMe[incompatible-call]
107
+ (0, _detachedNode.asDetachedNode)({
108
+ type: 'InterpreterDirective',
109
+ value: props.interpreter
110
+ }) : null,
111
+ docblock: props.docblock
112
+ });
113
+ } // the type annotation is stored on the Identifier's typeAnnotation
114
+ // which is super awkward to work with and type - so we flatten the input
115
+ // and put it in the right spot after
116
+
117
+
118
+ function DeclareFunction(props) {
119
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
120
+ type: 'DeclareFunction',
121
+ id: (0, _detachedNode.detachedProps)(null, {
122
+ type: 'Identifier',
123
+ name: props.name,
124
+ typeAnnotation: (0, _detachedNode.detachedProps)(null, {
125
+ type: 'TypeAnnotation',
126
+ typeAnnotation: (0, _detachedNode.asDetachedNode)(props.functionType)
127
+ })
128
+ }),
129
+ // $FlowFixMe[incompatible-call]
130
+ predicate: (0, _detachedNode.asDetachedNode)(props.predicate)
131
+ });
132
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
133
+ return node;
134
+ }
135
+
136
+ function MemberExpression(props) {
137
+ var _props$optional2;
138
+
139
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
140
+ type: 'MemberExpression',
141
+ object: (0, _detachedNode.asDetachedNode)(props.object),
142
+ property: (0, _detachedNode.asDetachedNode)(props.property),
143
+ computed: props.computed,
144
+ optional: (_props$optional2 = props.optional) != null ? _props$optional2 : false
145
+ });
146
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
147
+ return node;
148
+ } // Ignore the hermes-specific `implicit` property.
149
+
150
+
151
+ function BlockStatement(props) {
152
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
153
+ type: 'BlockStatement',
154
+ body: props.body.map(n => (0, _detachedNode.asDetachedNode)(n))
155
+ });
156
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
157
+ return node;
158
+ }