hermes-transform 0.10.0 → 0.11.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.
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.asDetachedNode = void 0;
7
+ exports.asDetachedNodeForCodeGen = asDetachedNodeForCodeGen;
7
8
  exports.deepCloneNode = deepCloneNode;
8
9
  exports.detachedProps = detachedProps;
9
10
  exports.getOriginalNode = getOriginalNode;
@@ -35,6 +36,21 @@ function getOriginalNode(node) {
35
36
  // $FlowExpectedError[prop-missing]
36
37
  return node[ORIGINAL_NODE];
37
38
  }
39
+ /* $FlowExpectedError[unclear-type] Type safety is not needed for generated
40
+ * code, this avoids us always having to pass a generic property within codegen */
41
+
42
+
43
+ function asDetachedNodeForCodeGen(node) {
44
+ if (node == null) {
45
+ return null;
46
+ }
47
+
48
+ if (isDetachedNode(node)) {
49
+ return node;
50
+ }
51
+
52
+ return shallowCloneNode(node, {});
53
+ }
38
54
 
39
55
  const asDetachedNode = (node, {
40
56
  useDeepClone
@@ -32,6 +32,20 @@ export function getOriginalNode(node: MaybeDetachedNode<ESNode>): ?ESNode {
32
32
  return node[ORIGINAL_NODE];
33
33
  }
34
34
 
35
+ /* $FlowExpectedError[unclear-type] Type safety is not needed for generated
36
+ * code, this avoids us always having to pass a generic property within codegen */
37
+ export function asDetachedNodeForCodeGen(node: any): ?DetachedNode<any> {
38
+ if (node == null) {
39
+ return null;
40
+ }
41
+
42
+ if (isDetachedNode(node)) {
43
+ return node;
44
+ }
45
+
46
+ return shallowCloneNode<ESNode>(node, {});
47
+ }
48
+
35
49
  export const asDetachedNode: {
36
50
  <T: ESNode>(
37
51
  node: MaybeDetachedNode<T>,
@@ -62,7 +76,7 @@ export const asDetachedNode: {
62
76
  // used by the node type function codegen
63
77
  export function detachedProps<T: BaseNode>(
64
78
  parent: ?ESNode,
65
- props: $ReadOnly<$Partial<{...}>>,
79
+ props: $ReadOnly<Partial<{...}>>,
66
80
  config: DetachConfig = {},
67
81
  ): DetachedNode<T> {
68
82
  // $FlowExpectedError[incompatible-type]
@@ -129,7 +143,7 @@ export function detachedProps<T: BaseNode>(
129
143
  */
130
144
  export function shallowCloneNode<T: ESNode>(
131
145
  node: T,
132
- newProps: $ReadOnly<$Partial<{...}>>,
146
+ newProps: $ReadOnly<Partial<{...}>>,
133
147
  config?: DetachConfig = {},
134
148
  ): DetachedNode<T> {
135
149
  return detachedProps(
@@ -148,7 +162,7 @@ export function shallowCloneNode<T: ESNode>(
148
162
  */
149
163
  export function deepCloneNode<T: ESNode>(
150
164
  node: T,
151
- newProps: $ReadOnly<$Partial<{...}>>,
165
+ newProps: $ReadOnly<Partial<{...}>>,
152
166
  ): DetachedNode<T> {
153
167
  const clone: DetachedNode<T> = Object.assign(
154
168
  JSON.parse(