@samitouri / QOS-React-2 / commits / 0ddcaafd7c

[babel] Inject React import if Forget compiled the function

Updates our Babel plugin to add an import to React if we succesfully compiled a function and cached one or more values. For now this logic is entirely in the Babel plugin itself, but long term we should move this into codegen and teach Forget to start the pipeline by lowering the whole Program node to an HIR (which would also allow us to understand imports and other module scope values being used). Right now it's not possible to add in codegen (without some ugly code) as a file containing multiple components would result in duplicate imports being generated

Lauren Tan committed Apr 17, 2023 at 17:49 UTC 0ddcaafd7c3c32ce92a14fe827781039cfbfd4fb
274 files changed +418 -60
compiler/forget/src/Babel/BabelPlugin.ts
+49 -5
@@ -191,11 +191,55 @@ export default function ReactForgetBabelPlugin(
191 opts: { ...pass.opts, ...options },
192 });
193
194 - if (options.gating != null && hasForgetCompiledCode) {
195 - path.unshiftContainer(
196 - "body",
197 - buildImportForGatingModule(options.gating)
198 - );
194 + // If there isn't already an import of * as React, insert it so React.useMemoCache doesn't
195 + // throw
196 + if (hasForgetCompiledCode) {
197 + let didInsertUseMemoCache = false;
198 + let hasExistingReactImport = false;
199 + path.traverse({
200 + MemberExpression(memberExprPath) {
201 + const obj = memberExprPath.get("object");
202 + const prop = memberExprPath.get("property");
203 + if (
204 + obj.isIdentifier() &&
205 + obj.node.name === "React" &&
206 + prop.isIdentifier() &&
207 + prop.node.name === "unstable_useMemoCache"
208 + ) {
209 + didInsertUseMemoCache = true;
210 + memberExprPath.stop();
211 + }
212 + },
213 + ImportDeclaration(importDeclPath) {
214 + if (
215 + importDeclPath.get("source").node.value === "react" &&
216 + importDeclPath.get("specifiers").length === 1 &&
217 + importDeclPath
218 + .get("specifiers")[0]
219 + .isImportNamespaceSpecifier() &&
220 + importDeclPath.get("specifiers")[0].get("local").node.name ===
221 + "React"
222 + ) {
223 + hasExistingReactImport = true;
224 + importDeclPath.stop();
225 + }
226 + },
227 + });
228 + if (didInsertUseMemoCache && !hasExistingReactImport) {
229 + path.unshiftContainer(
230 + "body",
231 + t.importDeclaration(
232 + [t.importNamespaceSpecifier(t.identifier("React"))],
233 + t.stringLiteral("react")
234 + )
235 + );
236 + }
237 + if (options.gating != null) {
238 + path.unshiftContainer(
239 + "body",
240 + buildImportForGatingModule(options.gating)
241 + );
242 + }
243 }
244 } catch (err) {
245 if (options.logger && err) {
compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md
+1 -1
@@ -23,7 +23,7 @@ function Component() {
23 ## Code
24
25 ```javascript
26 -// Should print A, B, arg, original
26 +import * as React from "react"; // Should print A, B, arg, original
27 function changeF(o) {
28 o.f = () => console.log("new");
29 return undefined;
compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md
+1
@@ -19,6 +19,7 @@ function Component() {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function Component() {
24 const $ = React.unstable_useMemoCache(1);
25 let t0;
compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component() {
22 ## Code
23
24 ```javascript
25 -// Should print A, arg, original
25 +import * as React from "react"; // Should print A, arg, original
26
27 function changeF(o) {
28 o.f = () => console.log("new");
compiler/forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md
+1
@@ -16,6 +16,7 @@ function component(a) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component(a) {
21 const $ = React.unstable_useMemoCache(2);
22 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path-mutate.expect.md
+1
@@ -17,6 +17,7 @@ function component() {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component() {
22 const $ = React.unstable_useMemoCache(1);
23 let x;
compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path.expect.md
+1
@@ -16,6 +16,7 @@ function component() {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component() {
21 const $ = React.unstable_useMemoCache(3);
22 let t0;
compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md
+1
@@ -26,6 +26,7 @@ function mutate(x, y) {}
26 ## Code
27
28 ```javascript
29 +import * as React from "react";
30 function foo(cond) {
31 const $ = React.unstable_useMemoCache(2);
32 const c_0 = $[0] !== cond;
compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md
+1 -1
@@ -19,7 +19,7 @@ function AllocatingPrimitiveAsDepNested(props) {
19 ## Code
20
21 ```javascript
22 -// bar(props.b) is an allocating expression that produces a primitive, which means
22 +import * as React from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
23 // that Forget should memoize it.
24 // Correctness:
25 // - y depends on either bar(props.b) or bar(props.b) + 1
compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md
+1 -1
@@ -16,7 +16,7 @@ function AllocatingPrimitiveAsDep(props) {
16 ## Code
17
18 ```javascript
19 -// bar(props.b) is an allocating expression that produces a primitive, which means
19 +import * as React from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
20 // that Forget should memoize it.
21 // Correctness:
22 // - y depends on either bar(props.b) or bar(props.b) + 1
compiler/forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md
+1
@@ -16,6 +16,7 @@ function foo(a, b, c) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function foo(a, b, c) {
21 const $ = React.unstable_useMemoCache(10);
22 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(7);
23 const c_0 = $[0] !== props.x;
compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md
+1 -1
@@ -17,7 +17,7 @@ function ArrayAtTest(props) {
17 ## Code
18
19 ```javascript
20 -// arrayInstance.at should have the following effects:
20 +import * as React from "react"; // arrayInstance.at should have the following effects:
21 // - read on arg0
22 // - read on receiver
23 // - mutate on lvalue
compiler/forget/src/__tests__/fixtures/compiler/array-at-mutate-after-capture.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 -// x's mutable range should extend to `mutate(y)`
21 +import * as React from "react"; // x's mutable range should extend to `mutate(y)`
22
23 function Component(props) {
24 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(3);
18 const c_0 = $[0] !== props.foo;
compiler/forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md
+1
@@ -13,6 +13,7 @@ function component([a, b]) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component(t17) {
18 const $ = React.unstable_useMemoCache(7);
19 const [a, b] = t17;
compiler/forget/src/__tests__/fixtures/compiler/array-properties.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(7);
20 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/array-property-call.expect.md
+1
@@ -15,6 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(11);
21 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md
+1 -1
@@ -19,7 +19,7 @@ function Component(props) {
19 ## Code
20
21 ```javascript
22 -// arrayInstance.push should have the following effects:
22 +import * as React from "react"; // arrayInstance.push should have the following effects:
23 // - read on all args (rest parameter)
24 // - mutate on receiver
25 function Component(props) {
compiler/forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md
+2 -1
@@ -12,7 +12,8 @@ export default ErrorView;
12 ## Code
13
14 ```javascript
15 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating
15 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
16 +import * as React from "react"; // @gating
17 function ErrorView_uncompiled(error, _retry) {
18 return <MessageBox error={error}></MessageBox>;
19 }
compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md
+1
@@ -15,6 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(2);
21 const c_0 = $[0] !== props.x;
compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md
+1
@@ -14,6 +14,7 @@ function g(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function g(props) {
19 const $ = React.unstable_useMemoCache(2);
20 const c_0 = $[0] !== props.c;
compiler/forget/src/__tests__/fixtures/compiler/assignment-in-nested-if.expect.md
+1
@@ -19,6 +19,7 @@ function useBar(props) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function useBar(props) {
24 const $ = React.unstable_useMemoCache(1);
25 let z;
compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue-array.expect.md
+1
@@ -14,6 +14,7 @@ function foo() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function foo() {
19 const $ = React.unstable_useMemoCache(2);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue.expect.md
+1
@@ -14,6 +14,7 @@ function g() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function g() {
19 const $ = React.unstable_useMemoCache(1);
20 let x;
compiler/forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md
+1
@@ -13,6 +13,7 @@ async function Component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 async function Component(props) {
18 const $ = React.unstable_useMemoCache(2);
19 const c_0 = $[0] !== props.id;
compiler/forget/src/__tests__/fixtures/compiler/await.expect.md
+1
@@ -12,6 +12,7 @@ async function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 async function Component(props) {
17 const $ = React.unstable_useMemoCache(4);
18 const c_0 = $[0] !== props.id;
compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md new
+75
@@ -0,0 +1,75 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import * as React from "react";
6 +import { useMemo } from "react";
7 +
8 +function Component(props) {
9 + const [x] = React.useState(0);
10 + const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
11 +
12 + return <div>{expensiveNumber}</div>;
13 +}
14 +
15 +function Component2(props) {
16 + const [x] = React.useState(0);
17 + const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
18 +
19 + return <div>{expensiveNumber}</div>;
20 +}
21 +
22 +```
23 +
24 +## Code
25 +
26 +```javascript
27 +import * as React from "react";
28 +import { useMemo } from "react";
29 +
30 +function Component(props) {
31 + const $ = React.unstable_useMemoCache(2);
32 + let t0;
33 + if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34 + const [x] = React.useState(0);
35 + t0 = calculateExpensiveNumber(x);
36 + $[0] = t0;
37 + } else {
38 + t0 = $[0];
39 + }
40 + const t17 = t0;
41 + const expensiveNumber = t17;
42 + let t1;
43 + if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
44 + t1 = <div>{expensiveNumber}</div>;
45 + $[1] = t1;
46 + } else {
47 + t1 = $[1];
48 + }
49 + return t1;
50 +}
51 +
52 +function Component2(props) {
53 + const $ = React.unstable_useMemoCache(2);
54 + let t0;
55 + if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
56 + const [x] = React.useState(0);
57 + t0 = calculateExpensiveNumber(x);
58 + $[0] = t0;
59 + } else {
60 + t0 = $[0];
61 + }
62 + const t17 = t0;
63 + const expensiveNumber = t17;
64 + let t1;
65 + if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
66 + t1 = <div>{expensiveNumber}</div>;
67 + $[1] = t1;
68 + } else {
69 + t1 = $[1];
70 + }
71 + return t1;
72 +}
73 +
74 +```
75 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.js new
+16
@@ -0,0 +1,16 @@
1 +import * as React from "react";
2 +import { useMemo } from "react";
3 +
4 +function Component(props) {
5 + const [x] = React.useState(0);
6 + const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
7 +
8 + return <div>{expensiveNumber}</div>;
9 +}
10 +
11 +function Component2(props) {
12 + const [x] = React.useState(0);
13 + const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
14 +
15 + return <div>{expensiveNumber}</div>;
16 +}
compiler/forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md
+1
@@ -13,6 +13,7 @@ function component(t) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component(t) {
18 const $ = React.unstable_useMemoCache(2);
19 const { a } = t;
compiler/forget/src/__tests__/fixtures/compiler/call-args-assignment.expect.md
+1
@@ -13,6 +13,7 @@ function Component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function Component(props) {
18 const $ = React.unstable_useMemoCache(1);
19 let x;
compiler/forget/src/__tests__/fixtures/compiler/call-args-destructuring-assignment.expect.md
+1
@@ -13,6 +13,7 @@ function Component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function Component(props) {
18 const $ = React.unstable_useMemoCache(1);
19 let x;
compiler/forget/src/__tests__/fixtures/compiler/call-spread.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(3);
18 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(6);
23 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/call.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo() {
23 return undefined;
24 }
compiler/forget/src/__tests__/fixtures/compiler/capture-func-passed-to-jsx.expect.md
+1
@@ -19,6 +19,7 @@ function component(a, b) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(a, b) {
24 const $ = React.unstable_useMemoCache(9);
25 const c_0 = $[0] !== b;
compiler/forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md
+1
@@ -19,6 +19,7 @@ function component(a) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(a) {
24 const $ = React.unstable_useMemoCache(2);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md
+1
@@ -45,6 +45,7 @@ function getNativeLogFunction(level) {
45 ## Code
46
47 ```javascript
48 +import * as React from "react";
49 function getNativeLogFunction(level) {
50 const $ = React.unstable_useMemoCache(2);
51 const c_0 = $[0] !== level;
compiler/forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md
+1
@@ -15,6 +15,7 @@ function component(a) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a) {
20 const $ = React.unstable_useMemoCache(4);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md
+1
@@ -19,6 +19,7 @@ function component(foo, bar) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(foo, bar) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== foo;
compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md
+1
@@ -19,6 +19,7 @@ function component(foo, bar) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(foo, bar) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== foo;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md
+1
@@ -19,6 +19,7 @@ function component(foo, bar) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(foo, bar) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== foo;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md
+1
@@ -19,6 +19,7 @@ function component(foo, bar) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(foo, bar) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== foo;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md
+1
@@ -18,6 +18,7 @@ function component(a) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md
+1
@@ -18,6 +18,7 @@ function component(a) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md
+1
@@ -18,6 +18,7 @@ function component(a, b) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a, b) {
23 const $ = React.unstable_useMemoCache(5);
24 const c_0 = $[0] !== b;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md
+1
@@ -17,6 +17,7 @@ function component(a, b) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a, b) {
22 const $ = React.unstable_useMemoCache(7);
23 const c_0 = $[0] !== b;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md
+1
@@ -16,6 +16,7 @@ function component(a) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component(a) {
21 const $ = React.unstable_useMemoCache(2);
22 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md
+1
@@ -18,6 +18,7 @@ function component(a, b) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a, b) {
23 const $ = React.unstable_useMemoCache(5);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md
+1
@@ -15,6 +15,7 @@ function component(a) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a) {
20 const $ = React.unstable_useMemoCache(4);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md
+1
@@ -17,6 +17,7 @@ function bar(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function bar(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md
+1
@@ -19,6 +19,7 @@ function bar(a, b) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function bar(a, b) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md
+1
@@ -17,6 +17,7 @@ function bar(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function bar(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md
+1
@@ -17,6 +17,7 @@ function bar(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function bar(a) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md
+1
@@ -22,6 +22,7 @@ function component(a, b) {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function component(a, b) {
27 const $ = React.unstable_useMemoCache(7);
28 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md
+1
@@ -18,6 +18,7 @@ function component(a, b) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a, b) {
23 const $ = React.unstable_useMemoCache(5);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md
+1
@@ -16,6 +16,7 @@ function component(a) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component(a) {
21 const $ = React.unstable_useMemoCache(2);
22 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md
+1
@@ -18,6 +18,7 @@ function Foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Foo(props) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== props.router.location;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md
+1
@@ -19,6 +19,7 @@ function component({ mutator }) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(t27) {
24 const $ = React.unstable_useMemoCache(7);
25 const { mutator } = t27;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md
+1
@@ -18,6 +18,7 @@ function component(a, b) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a, b) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md
+1
@@ -13,6 +13,7 @@ function component(a, b) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component(a, b) {
18 const $ = React.unstable_useMemoCache(6);
19 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md
+1
@@ -16,6 +16,7 @@ function component(a) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component(a) {
21 const $ = React.unstable_useMemoCache(1);
22 let t0;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md
+1
@@ -12,6 +12,7 @@ function StoreLandingUnseenGiftModalContainer(a) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function StoreLandingUnseenGiftModalContainer(a) {
17 const $ = React.unstable_useMemoCache(2);
18 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md
+1
@@ -18,6 +18,7 @@ function component(a) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(a) {
23 const $ = React.unstable_useMemoCache(4);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md
+1
@@ -15,6 +15,7 @@ function component(a) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a) {
20 const $ = React.unstable_useMemoCache(4);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md
+1
@@ -15,6 +15,7 @@ function component(a) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a) {
20 const $ = React.unstable_useMemoCache(6);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(6);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md
+1
@@ -15,6 +15,7 @@ function component(a) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a) {
20 const $ = React.unstable_useMemoCache(6);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(4);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md
+1
@@ -17,6 +17,7 @@ function component(a) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function component(a) {
22 const $ = React.unstable_useMemoCache(4);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/chained-assignment-expressions.expect.md
+1
@@ -16,6 +16,7 @@ function foo() {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function foo() {
21 const $ = React.unstable_useMemoCache(1);
22 let z;
compiler/forget/src/__tests__/fixtures/compiler/component.expect.md
+1
@@ -34,6 +34,7 @@ function Component(props) {
34 ## Code
35
36 ```javascript
37 +import * as React from "react";
38 function Component(props) {
39 const $ = React.unstable_useMemoCache(8);
40 const items = props.items;
compiler/forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(4);
18 const c_0 = $[0] !== props.method;
compiler/forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(2);
23 const a = foo();
compiler/forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md
+1
@@ -15,6 +15,7 @@ function component(a, b) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a, b) {
20 const $ = React.unstable_useMemoCache(3);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md
+1
@@ -13,6 +13,7 @@ function component() {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component() {
18 const $ = React.unstable_useMemoCache(4);
19 const [x, setX] = useState(0);
compiler/forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md
+1 -1
@@ -17,7 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 -// To preserve the nullthrows behavior and reactive deps of this code,
20 +import * as React from "react"; // To preserve the nullthrows behavior and reactive deps of this code,
21 // Forget needs to add `props.a` as a dependency (since `props.a.b` is
22 // a conditional dependency, i.e. gated behind control flow)
23
compiler/forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md
+1
@@ -23,6 +23,7 @@ function Component(props) {
23 ## Code
24
25 ```javascript
26 +import * as React from "react";
27 /**
28 * props.b *does* influence `a`
29 */
compiler/forget/src/__tests__/fixtures/compiler/conditional-break.expect.md
+1
@@ -61,6 +61,7 @@ function ComponentD(props) {
61 ## Code
62
63 ```javascript
64 +import * as React from "react";
65 /**
66 * props.b does *not* influence `a`
67 */
compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md
+1
@@ -34,6 +34,7 @@ function mayMutate() {}
34 ## Code
35
36 ```javascript
37 +import * as React from "react";
38 function ComponentA(props) {
39 const $ = React.unstable_useMemoCache(6);
40 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md
+1
@@ -15,6 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(2);
21 const c_0 = $[0] !== props.foo;
compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Foo() {
23 return undefined;
24 }
compiler/forget/src/__tests__/fixtures/compiler/controlled-input.expect.md
+1
@@ -13,6 +13,7 @@ function component() {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component() {
18 const $ = React.unstable_useMemoCache(5);
19 const [x, setX] = useState(0);
compiler/forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(3);
20 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/delete-property.expect.md
+1
@@ -13,6 +13,7 @@ function Component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function Component(props) {
18 const $ = React.unstable_useMemoCache(3);
19 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md
+1
@@ -22,6 +22,7 @@ function foo(a, b) {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function foo(a, b) {
27 const $ = React.unstable_useMemoCache(5);
28 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/dependencies.expect.md
+1
@@ -23,6 +23,7 @@ function foo(x, y, z) {
23 ## Code
24
25 ```javascript
26 +import * as React from "react";
27 function foo(x, y, z) {
28 const $ = React.unstable_useMemoCache(3);
29 const items = [z];
compiler/forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md
+1
@@ -13,6 +13,7 @@ function component(a) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 let someGlobal = {};
18 function component(a) {
19 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(2);
18 const [t0] = props.y;
compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(2);
23 let x = undefined;
compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md
+1
@@ -26,6 +26,7 @@ function foo(a, b, c) {
26 ## Code
27
28 ```javascript
29 +import * as React from "react";
30 function foo(a, b, c) {
31 const $ = React.unstable_useMemoCache(5);
32
compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(2);
18 const { x: t0 } = props.y;
compiler/forget/src/__tests__/fixtures/compiler/destructuring.expect.md
+1
@@ -27,6 +27,7 @@ function foo(a, b, c) {
27 ## Code
28
29 ```javascript
30 +import * as React from "react";
31 function foo(a, b, c) {
32 const $ = React.unstable_useMemoCache(18);
33 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(2);
23 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/do-while-continue.expect.md
+1
@@ -21,6 +21,7 @@ function Component() {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function Component() {
26 const $ = React.unstable_useMemoCache(1);
27 let ret;
compiler/forget/src/__tests__/fixtures/compiler/do-while-early-unconditional-break.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(1);
22 let x;
compiler/forget/src/__tests__/fixtures/compiler/do-while-simple.expect.md
+1
@@ -17,6 +17,7 @@ function Component() {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function Component() {
22 const $ = React.unstable_useMemoCache(1);
23 let ret;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md
+1
@@ -15,6 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(7);
21 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a, b, c) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a, b, c) {
24 const $ = React.unstable_useMemoCache(9);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(10);
22 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md
+1
@@ -23,6 +23,7 @@ function Component(props) {
23 ## Code
24
25 ```javascript
26 +import * as React from "react";
27 function Component(props) {
28 const $ = React.unstable_useMemoCache(5);
29 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md
+1
@@ -32,6 +32,7 @@ function Component(props) {
32 ## Code
33
34 ```javascript
35 +import * as React from "react";
36 function Component(props) {
37 const $ = React.unstable_useMemoCache(7);
38 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md
+1
@@ -25,6 +25,7 @@ function Component(props) {
25 ## Code
26
27 ```javascript
28 +import * as React from "react";
29 function Component(props) {
30 const $ = React.unstable_useMemoCache(3);
31
compiler/forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md
+1
@@ -22,6 +22,7 @@ function foo(a, b, c) {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function foo(a, b, c) {
27 const $ = React.unstable_useMemoCache(4);
28 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 import fbt from "fbt";
22
23 function Component(props) {
compiler/forget/src/__tests__/fixtures/compiler/fbt-call.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 import fbt from "fbt";
22
23 function Component(props) {
compiler/forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 import fbt from "fbt";
22
23 function Component(props) {
compiler/forget/src/__tests__/fixtures/compiler/fbt-params.expect.md
+1
@@ -17,6 +17,7 @@ function Component(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 import fbt from "fbt";
22
23 function Component(props) {
compiler/forget/src/__tests__/fixtures/compiler/for-of-break.expect.md
+1
@@ -15,6 +15,7 @@ function Component() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component() {
20 const $ = React.unstable_useMemoCache(1);
21 let t0;
compiler/forget/src/__tests__/fixtures/compiler/for-of-conditional-break.expect.md
+1
@@ -18,6 +18,7 @@ function Component() {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component() {
23 const $ = React.unstable_useMemoCache(2);
24 let x;
compiler/forget/src/__tests__/fixtures/compiler/for-of-continue.expect.md
+1
@@ -19,6 +19,7 @@ function Component() {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function Component() {
24 const $ = React.unstable_useMemoCache(2);
25 let t0;
compiler/forget/src/__tests__/fixtures/compiler/for-of-destructure.expect.md
+1
@@ -16,6 +16,7 @@ function Component() {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component() {
21 const $ = React.unstable_useMemoCache(1);
22 let x;
compiler/forget/src/__tests__/fixtures/compiler/for-of-mutate.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(2);
22 let results;
compiler/forget/src/__tests__/fixtures/compiler/for-of-simple.expect.md
+1
@@ -16,6 +16,7 @@ function Component() {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component() {
21 const $ = React.unstable_useMemoCache(1);
22 let x;
compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md
+1
@@ -18,6 +18,7 @@ function foo(x) {}
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component() {
23 const $ = React.unstable_useMemoCache(1);
24 let t0;
compiler/forget/src/__tests__/fixtures/compiler/function-declaration-reassign.expect.md
+1
@@ -15,6 +15,7 @@ function component() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component() {
20 const $ = React.unstable_useMemoCache(1);
21 let t0;
compiler/forget/src/__tests__/fixtures/compiler/function-declaration-redeclare.expect.md
+1
@@ -15,6 +15,7 @@ function component() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component() {
20 const $ = React.unstable_useMemoCache(1);
21 let t0;
compiler/forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md
+1
@@ -16,6 +16,7 @@ function component(a) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function component(a) {
21 const $ = React.unstable_useMemoCache(3);
22 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md
+1
@@ -11,6 +11,7 @@ function Component(x = "default", y = [{}]) {
11 ## Code
12
13 ```javascript
14 +import * as React from "react";
15 function Component(t24, t0) {
16 const $ = React.unstable_useMemoCache(5);
17 const x = t24 === undefined ? "default" : t24;
compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md
+2 -1
@@ -22,7 +22,8 @@ function Foo(props) {
22 ## Code
23
24 ```javascript
25 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating @forgetDirective
25 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
26 +import * as React from "react"; // @gating @forgetDirective
27 function Bar_uncompiled(props) {
28 "use forget";
29 return <div>{props.bar}</div>;
compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md
+2 -1
@@ -22,7 +22,8 @@ export function Foo(props) {
22 ## Code
23
24 ```javascript
25 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating @forgetDirective
25 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
26 +import * as React from "react"; // @gating @forgetDirective
27 function Bar_uncompiled(props) {
28 "use forget";
29 return <div>{props.bar}</div>;
compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md
+2 -1
@@ -22,7 +22,8 @@ export function Foo(props) {
22 ## Code
23
24 ```javascript
25 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating @forgetDirective
25 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
26 +import * as React from "react"; // @gating @forgetDirective
27 function Bar_uncompiled(props) {
28 "use forget";
29 return <div>{props.bar}</div>;
compiler/forget/src/__tests__/fixtures/compiler/gating-test.expect.md
+2 -1
@@ -22,7 +22,8 @@ function Foo(props) {
22 ## Code
23
24 ```javascript
25 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating @forgetDirective
25 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
26 +import * as React from "react"; // @gating @forgetDirective
27 function Bar_uncompiled(props) {
28 "use forget";
29 return <div>{props.bar}</div>;
compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md
+1
@@ -22,6 +22,7 @@ function Component(props) {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function useFreeze() {
27 return undefined;
28 }
compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md
+1
@@ -18,6 +18,7 @@ function call(x) {}
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component() {
23 const $ = React.unstable_useMemoCache(1);
24 let t0;
compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md
+1
@@ -25,6 +25,7 @@ function call(x) {}
25 ## Code
26
27 ```javascript
28 +import * as React from "react";
29 function Component(props) {
30 const $ = React.unstable_useMemoCache(1);
31 const cond = props.cond;
compiler/forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md
+1
@@ -21,6 +21,7 @@ function Component(props) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function Component(props) {
26 const $ = React.unstable_useMemoCache(4);
27 const [value, setValue] = useState(null);
compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md
+1
@@ -36,6 +36,7 @@ function Component(props) {
36 ## Code
37
38 ```javascript
39 +import * as React from "react";
40 function compute() {
41 return undefined;
42 }
compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md
+1
@@ -27,6 +27,7 @@ function Foo() {}
27 ## Code
28
29 ```javascript
30 +import * as React from "react";
31 /**
32 * Should produce 3 scopes:
33 *
compiler/forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md
+1
@@ -15,6 +15,7 @@ function foo(a, b, c) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function foo(a, b, c) {
20 const $ = React.unstable_useMemoCache(7);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md
+1 -1
@@ -21,7 +21,7 @@ function Component(props) {
21 ## Code
22
23 ```javascript
24 -// Check that we correctly resolve type and effect lookups on the javascript
24 +import * as React from "react"; // Check that we correctly resolve type and effect lookups on the javascript
25 // global object.
26 function Component(props) {
27 const $ = React.unstable_useMemoCache(7);
compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md
+1
@@ -30,6 +30,7 @@ function Component(props) {
30 ## Code
31
32 ```javascript
33 +import * as React from "react";
34 function compute() {
35 return undefined;
36 }
compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md
+1
@@ -27,6 +27,7 @@ function Foo() {}
27 ## Code
28
29 ```javascript
30 +import * as React from "react";
31 /**
32 * Should produce 1 scope:
33 *
compiler/forget/src/__tests__/fixtures/compiler/inverted-if.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a, b, c, d) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a, b, c, d) {
24 const $ = React.unstable_useMemoCache(5);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/issue933-disjoint-set-infinite-loop.expect.md
+1 -1
@@ -16,7 +16,7 @@ function MyApp(props) {
16 ## Code
17
18 ```javascript
19 -// This caused an infinite loop in the compiler
19 +import * as React from "react"; // This caused an infinite loop in the compiler
20 function MyApp(props) {
21 const $ = React.unstable_useMemoCache(1);
22 let y;
compiler/forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md
+1
@@ -16,6 +16,7 @@ export function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 export function Component(props) {
21 const $ = React.unstable_useMemoCache(2);
22 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md
+1
@@ -18,6 +18,7 @@ function Foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Foo(props) {
23 const $ = React.unstable_useMemoCache(4);
24 let t0;
compiler/forget/src/__tests__/fixtures/compiler/jsx-member-expression.expect.md
+1
@@ -15,6 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(2);
21 let t0;
compiler/forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md
+1
@@ -11,6 +11,7 @@ function Component(props) {
11 ## Code
12
13 ```javascript
14 +import * as React from "react";
15 function Component(props) {
16 const $ = React.unstable_useMemoCache(2);
17 const c_0 = $[0] !== props.version;
compiler/forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md
+1
@@ -13,6 +13,7 @@ function Component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function Component(props) {
18 const $ = React.unstable_useMemoCache(5);
19
compiler/forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md
+1 -1
@@ -26,7 +26,7 @@ function CaptureNotMutate(props) {
26 ## Code
27
28 ```javascript
29 -// Here, element should not be memoized independently of aliasedElement, since
29 +import * as React from "react"; // Here, element should not be memoized independently of aliasedElement, since
30 // it is captured by fn.
31 // AnalyzeFunctions currently does not find captured objects.
32 // - mutated context refs are declared as `Capture` effect in `FunctionExpression.deps`
compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md
+1
@@ -19,6 +19,7 @@ function Component() {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function Component() {
24 const $ = React.unstable_useMemoCache(1);
25 let t0;
compiler/forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md
+1
@@ -18,6 +18,7 @@ function component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component(props) {
23 const $ = React.unstable_useMemoCache(3);
24
compiler/forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md
+1
@@ -21,6 +21,7 @@ function foo(a, b, c) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function foo(a, b, c) {
26 const $ = React.unstable_useMemoCache(8);
27 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md
+1
@@ -18,6 +18,7 @@ function foo(a, b, c) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(a, b, c) {
23 const $ = React.unstable_useMemoCache(6);
24 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/method-call.expect.md
+1
@@ -17,6 +17,7 @@ function foo(a, b, c) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function foo(a, b, c) {
22 const $ = React.unstable_useMemoCache(5);
23 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md
+2 -1
@@ -17,7 +17,8 @@ export const Renderer = (props) => (
17 ## Code
18
19 ```javascript
20 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating
20 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
21 +import * as React from "react"; // @gating
22 function ErrorView_uncompiled(error, _retry) {
23 return <MessageBox error={error}></MessageBox>;
24 }
compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md
+2 -1
@@ -19,7 +19,8 @@ export default Renderer;
19 ## Code
20
21 ```javascript
22 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; // @gating
22 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
23 +import * as React from "react"; // @gating
24 function ErrorView_uncompiled(error, _retry) {
25 return <MessageBox error={error}></MessageBox>;
26 }
compiler/forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(5);
24 const [x, setX] = useState(null);
compiler/forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md
+1 -1
@@ -14,7 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 -// We should codegen nested optional properties correctly
17 +import * as React from "react"; // We should codegen nested optional properties correctly
18 // (i.e. placing `?` in the correct PropertyLoad)
19 function Component(props) {
20 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/new-spread.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(3);
18 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md
+1
@@ -18,6 +18,7 @@ function foo(a, b, c, d) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(a, b, c, d) {
23 const $ = React.unstable_useMemoCache(4);
24 let x = undefined;
compiler/forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a, b, c, d) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a, b, c, d) {
24 const $ = React.unstable_useMemoCache(3);
25 const c_0 = $[0] !== b;
compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md
+1
@@ -21,6 +21,7 @@ function foo(a, b, c, d) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function foo(a, b, c, d) {
26 const $ = React.unstable_useMemoCache(2);
27 someObj();
compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a, b, c, d) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a, b, c, d) {
24 const $ = React.unstable_useMemoCache(2);
25 someObj();
compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md
+1
@@ -27,6 +27,7 @@ function foo(a, b, c, d) {
27 ## Code
28
29 ```javascript
30 +import * as React from "react";
31 function foo(a, b, c, d) {
32 const $ = React.unstable_useMemoCache(3);
33 someObj();
compiler/forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(2);
18 const c_0 = $[0] !== props.foo;
compiler/forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(2);
18 const c_0 = $[0] !== props.foo;
compiler/forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md
+1
@@ -13,6 +13,7 @@ function component({ a, b }) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component(t17) {
18 const $ = React.unstable_useMemoCache(7);
19 const { a, b } = t17;
compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md
+1
@@ -21,6 +21,7 @@ function Component(props) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function Component(props) {
26 const $ = React.unstable_useMemoCache(2);
27 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/optional-call.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(2);
20 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md
+1 -1
@@ -15,7 +15,7 @@ function Component(props) {
15 ## Code
16
17 ```javascript
18 -// Note that `a?.b.c` is semantically different from `(a?.b).c`
18 +import * as React from "react"; // Note that `a?.b.c` is semantically different from `(a?.b).c`
19 // We should codegen the correct member expressions
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(3);
compiler/forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(2);
20 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(2);
20 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(2);
20 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md
+1
@@ -20,6 +20,7 @@ function foo(a, b, c) {
20 ## Code
21
22 ```javascript
23 +import * as React from "react";
24 function foo(a, b, c) {
25 const $ = React.unstable_useMemoCache(9);
26 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md
+1
@@ -20,6 +20,7 @@ function foo(a, b, c) {
20 ## Code
21
22 ```javascript
23 +import * as React from "react";
24 function foo(a, b, c) {
25 const $ = React.unstable_useMemoCache(7);
26 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md
+1 -1
@@ -20,7 +20,7 @@ function PrimitiveAsDepNested(props) {
20 ## Code
21
22 ```javascript
23 -// props.b + 1 is an non-allocating expression, which means Forget can
23 +import * as React from "react"; // props.b + 1 is an non-allocating expression, which means Forget can
24 // emit it trivially and repeatedly (e.g. no need to memoize props.b + 1
25 // separately from props.b)
26 // Correctness:
compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md
+1 -1
@@ -17,7 +17,7 @@ function PrimitiveAsDep(props) {
17 ## Code
18
19 ```javascript
20 -// props.b + 1 is an non-allocating expression, which means Forget can
20 +import * as React from "react"; // props.b + 1 is an non-allocating expression, which means Forget can
21 // emit it trivially and repeatedly (e.g. no need to memoize props.b + 1
22 // separately from props.b)
23 // Correctness:
compiler/forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md
+1
@@ -15,6 +15,7 @@ function component(a, b) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component(a, b) {
20 const $ = React.unstable_useMemoCache(5);
21 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/property-assignment.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(6);
22 const c_0 = $[0] !== props.p0;
compiler/forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md
+1
@@ -12,6 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function Component(props) {
17 const $ = React.unstable_useMemoCache(3);
18 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/reactive-scope-grouping.expect.md
+1
@@ -17,6 +17,7 @@ function foo() {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function foo() {
22 const $ = React.unstable_useMemoCache(3);
23 let x;
compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a, b, c) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a, b, c) {
24 const $ = React.unstable_useMemoCache(8);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md
+1
@@ -18,6 +18,7 @@ function f(a, b) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function f(a, b) {
23 const $ = React.unstable_useMemoCache(5);
24 const c_0 = $[0] !== a.length;
compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md
+1
@@ -27,6 +27,7 @@ function Component(props) {
27 ## Code
28
29 ```javascript
30 +import * as React from "react";
31 function Component(props) {
32 const $ = React.unstable_useMemoCache(6);
33 const c_0 = $[0] !== props.b;
compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(8);
22 const c_0 = $[0] !== props.key;
compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Component(props) {
21 const $ = React.unstable_useMemoCache(7);
22 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md
+1
@@ -21,6 +21,7 @@ function Component(props) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function Component(props) {
26 const $ = React.unstable_useMemoCache(9);
27 const c_0 = $[0] !== props.p0;
compiler/forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md
+1
@@ -33,6 +33,7 @@ function foo(a, b, c) {
33 ## Code
34
35 ```javascript
36 +import * as React from "react";
37 function foo(a, b, c) {
38 const $ = React.unstable_useMemoCache(11);
39 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/reassignment.expect.md
+1
@@ -20,6 +20,7 @@ function Component(props) {
20 ## Code
21
22 ```javascript
23 +import * as React from "react";
24 function Component(props) {
25 const $ = React.unstable_useMemoCache(8);
26 const c_0 = $[0] !== props.p0;
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md
+1 -1
@@ -16,7 +16,7 @@ function TestCondDepInConditionalExpr(props, other) {
16 ## Code
17
18 ```javascript
19 -// props.a.b should be added as a unconditional dependency to the reactive
19 +import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive
20 // scope that produces x, since it is accessed unconditionally in all cfg
21 // paths
22
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md
+1 -1
@@ -21,7 +21,7 @@ function TestCondDepInDirectIfElse(props, other) {
21 ## Code
22
23 ```javascript
24 -// props.a.b should be added as a unconditional dependency to the reactive
24 +import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive
25 // scope that produces x, since it is accessed unconditionally in all cfg
26 // paths
27
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md
+1 -1
@@ -22,7 +22,7 @@ function TestCondDepInNestedIfElse(props, other) {
22 ## Code
23
24 ```javascript
25 -// props.a.b should NOT be added as a unconditional dependency to the reactive
25 +import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive
26 // scope that produces x if it is not accessed in every path
27
28 function TestCondDepInNestedIfElse(props, other) {
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md
+1 -1
@@ -27,7 +27,7 @@ function TestCondDepInNestedIfElse(props, other) {
27 ## Code
28
29 ```javascript
30 -// props.a.b should be added as a unconditional dependency to the reactive
30 +import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive
31 // scope that produces x, since it is accessed unconditionally in all cfg
32 // paths
33
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md
+1 -1
@@ -26,7 +26,7 @@ function TestCondDepInSwitchMissingCase(props, other) {
26 ## Code
27
28 ```javascript
29 -// props.a.b should NOT be added as a unconditional dependency to the reactive
29 +import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive
30 // scope that produces x if it is not accessed in every path
31
32 function TestCondDepInSwitchMissingCase(props, other) {
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md
+1 -1
@@ -23,7 +23,7 @@ function TestCondDepInSwitchMissingDefault(props, other) {
23 ## Code
24
25 ```javascript
26 -// props.a.b should NOT be added as a unconditional dependency to the reactive
26 +import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive
27 // scope that produces x if it is not accessed in the default case.
28
29 function TestCondDepInSwitchMissingDefault(props, other) {
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md
+1 -1
@@ -26,7 +26,7 @@ function TestCondDepInSwitch(props, other) {
26 ## Code
27
28 ```javascript
29 -// props.a.b should be added as a unconditional dependency to the reactive
29 +import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive
30 // scope that produces x, since it is accessed unconditionally in all cfg
31 // paths
32
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md
+1 -1
@@ -18,7 +18,7 @@ function TestOnlyConditionalDependencies(props, other) {
18 ## Code
19
20 ```javascript
21 -// When an object's properties are only read conditionally, we should
21 +import * as React from "react"; // When an object's properties are only read conditionally, we should
22 // track the base object as a dependency.
23 function TestOnlyConditionalDependencies(props, other) {
24 const $ = React.unstable_useMemoCache(3);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md
+1 -1
@@ -19,7 +19,7 @@ function TestPromoteUnconditionalAccessToDependency(props, other) {
19 ## Code
20
21 ```javascript
22 -// When a conditional dependency `props.a.b.c` has no unconditional dependency
22 +import * as React from "react"; // When a conditional dependency `props.a.b.c` has no unconditional dependency
23 // in its subpath or superpath, we should find the nearest unconditional access
24 // and promote it to an unconditional dependency.
25 function TestPromoteUnconditionalAccessToDependency(props, other) {
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md
+1 -1
@@ -21,7 +21,7 @@ function TestConditionalSubpath1(props, other) {
21 ## Code
22
23 ```javascript
24 -// When a conditional dependency `props.a` is a subpath of an unconditional
24 +import * as React from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional
25 // dependency `props.a.b`, we can access `props.a` while preserving program
26 // semantics (with respect to nullthrows).
27 // deps: {`props.a`, `props.a.b`} can further reduce to just `props.a`
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md
+1 -1
@@ -21,7 +21,7 @@ function TestConditionalSubpath2(props, other) {
21 ## Code
22
23 ```javascript
24 -// When a conditional dependency `props.a` is a subpath of an unconditional
24 +import * as React from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional
25 // dependency `props.a.b`, we can access `props.a` while preserving program
26 // semantics (with respect to nullthrows).
27 // deps: {`props.a`, `props.a.b`} can further reduce to just `props.a`
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md
+1 -1
@@ -20,7 +20,7 @@ function TestConditionalSuperpath1(props, other) {
20 ## Code
21
22 ```javascript
23 -// When an unconditional dependency `props.a` is the subpath of a conditional
23 +import * as React from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional
24 // dependency `props.a.b`, we can safely overestimate and only track `props.a`
25 // as a dependency
26 // ordering of accesses should not matter
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md
+1 -1
@@ -20,7 +20,7 @@ function TestConditionalSuperpath2(props, other) {
20 ## Code
21
22 ```javascript
23 -// When an unconditional dependency `props.a` is the subpath of a conditional
23 +import * as React from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional
24 // dependency `props.a.b`, we can safely overestimate and only track `props.a`
25 // as a dependency
26 // ordering of accesses should not matter
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md
+1 -1
@@ -25,7 +25,7 @@ function Component(props) {
25 ## Code
26
27 ```javascript
28 -// To preserve the nullthrows behavior and reactive deps of this code,
28 +import * as React from "react"; // To preserve the nullthrows behavior and reactive deps of this code,
29 // Forget needs to add `props.a.b` or a subpath as a dependency.
30 //
31 // (1) Since the reactive block producing x unconditionally read props.a.<...>,
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md
+1 -1
@@ -34,7 +34,7 @@ function TestReactiveDepsInCondScope(props) {
34 ## Code
35
36 ```javascript
37 -// Some reactive scopes are created within a conditional. If a child scope
37 +import * as React from "react"; // Some reactive scopes are created within a conditional. If a child scope
38 // is within a conditional, its reactive dependencies should be propagated
39 // as conditionals
40 //
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md
+1 -1
@@ -34,7 +34,7 @@ function TestJoinCondDepsInUncondScopes(props) {
34 ## Code
35
36 ```javascript
37 -// This tests an optimization, NOT a correctness property.
37 +import * as React from "react"; // This tests an optimization, NOT a correctness property.
38 // When propagating reactive dependencies of an inner scope up to its parent,
39 // we prefer to retain granularity.
40 //
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestNonOverlappingDescendantTracked(props) {
17 ## Code
18
19 ```javascript
20 -// Test that we can track non-overlapping dependencies separately.
20 +import * as React from "react"; // Test that we can track non-overlapping dependencies separately.
21 // (not needed for correctness but for dependency granularity)
22 function TestNonOverlappingDescendantTracked(props) {
23 const $ = React.unstable_useMemoCache(4);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md
+1 -1
@@ -16,7 +16,7 @@ function TestNonOverlappingTracked(props) {
16 ## Code
17
18 ```javascript
19 -// Test that we can track non-overlapping dependencies separately.
19 +import * as React from "react"; // Test that we can track non-overlapping dependencies separately.
20 // (not needed for correctness but for dependency granularity)
21 function TestNonOverlappingTracked(props) {
22 const $ = React.unstable_useMemoCache(3);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestOverlappingDescendantTracked(props) {
17 ## Code
18
19 ```javascript
20 -// Test that we correctly track a subpath if the subpath itself is accessed as
20 +import * as React from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as
21 // a dependency
22 function TestOverlappingDescendantTracked(props) {
23 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestOverlappingTracked(props) {
17 ## Code
18
19 ```javascript
20 -// Test that we correctly track a subpath if the subpath itself is accessed as
20 +import * as React from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as
21 // a dependency
22 function TestOverlappingTracked(props) {
23 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestDepsSubpathOrder1(props) {
17 ## Code
18
19 ```javascript
20 -// Determine that we only need to track p.a here
20 +import * as React from "react"; // Determine that we only need to track p.a here
21 // Ordering of access should not matter
22 function TestDepsSubpathOrder1(props) {
23 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestDepsSubpathOrder2(props) {
17 ## Code
18
19 ```javascript
20 -// Determine that we only need to track p.a here
20 +import * as React from "react"; // Determine that we only need to track p.a here
21 // Ordering of access should not matter
22 function TestDepsSubpathOrder2(props) {
23 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md
+1 -1
@@ -17,7 +17,7 @@ function TestDepsSubpathOrder3(props) {
17 ## Code
18
19 ```javascript
20 -// Determine that we only need to track p.a here
20 +import * as React from "react"; // Determine that we only need to track p.a here
21 // Ordering of access should not matter
22 function TestDepsSubpathOrder3(props) {
23 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(4);
24 let t0;
compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md
+1 -1
@@ -43,7 +43,7 @@ function foo(props) {
43 ## Code
44
45 ```javascript
46 -// note: comments are for the ideal scopes, not what is currently
46 +import * as React from "react"; // note: comments are for the ideal scopes, not what is currently
47 // emitted
48 function foo(props) {
49 const $ = React.unstable_useMemoCache(16);
compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md
+1 -1
@@ -43,7 +43,7 @@ function foo(props) {
43 ## Code
44
45 ```javascript
46 -// note: comments are for the ideal scopes, not what is currently
46 +import * as React from "react"; // note: comments are for the ideal scopes, not what is currently
47 // emitted
48 function foo(props) {
49 const $ = React.unstable_useMemoCache(15);
compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md
+1
@@ -17,6 +17,7 @@ function foo() {}
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function sequence(props) {
22 const $ = React.unstable_useMemoCache(2);
23 Math.max(1, 2);
compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md
+1
@@ -19,6 +19,7 @@ function foo() {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function mutate() {
24 return undefined;
25 }
compiler/forget/src/__tests__/fixtures/compiler/simple-function-1.expect.md
+1
@@ -14,6 +14,7 @@ function component() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function component() {
19 const $ = React.unstable_useMemoCache(1);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/simple-scope.expect.md
+1
@@ -12,6 +12,7 @@ function foo(a) {
12 ## Code
13
14 ```javascript
15 +import * as React from "react";
16 function foo(a) {
17 const $ = React.unstable_useMemoCache(2);
18 const c_0 = $[0] !== a.b;
compiler/forget/src/__tests__/fixtures/compiler/simple.expect.md
+1
@@ -14,6 +14,7 @@ export default function foo(x, y) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 export default function foo(x, y) {
19 const $ = React.unstable_useMemoCache(4);
20 if (x) {
compiler/forget/src/__tests__/fixtures/compiler/ssa-arrayexpression.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(1);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md
+1 -1
@@ -21,7 +21,7 @@ function Component(props) {
21 ## Code
22
23 ```javascript
24 -// @Pass runMutableRangeAnalysis
24 +import * as React from "react"; // @Pass runMutableRangeAnalysis
25 function foo() {
26 return undefined;
27 }
compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo() {
23 return undefined;
24 }
compiler/forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md
+1
@@ -23,6 +23,7 @@ function Component(props) {
23 ## Code
24
25 ```javascript
26 +import * as React from "react";
27 function Component(props) {
28 const $ = React.unstable_useMemoCache(2);
29 let x = 0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-for-of.expect.md
+1
@@ -18,6 +18,7 @@ function foo(cond) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(cond) {
23 const $ = React.unstable_useMemoCache(1);
24 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md
+1
@@ -22,6 +22,7 @@ function Component(props) {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function Component(props) {
27 const $ = React.unstable_useMemoCache(6);
28 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md
+1
@@ -16,6 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function Foo() {
21 return undefined;
22 }
compiler/forget/src/__tests__/fixtures/compiler/ssa-non-empty-initializer.expect.md
+1
@@ -17,6 +17,7 @@ function foo(a, b) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function foo(a, b) {
22 const $ = React.unstable_useMemoCache(1);
23 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression-phi.expect.md
+1
@@ -21,6 +21,7 @@ function foo() {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function foo() {
26 const $ = React.unstable_useMemoCache(1);
27 const x = 1;
compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression.expect.md
+1
@@ -14,6 +14,7 @@ function Component(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Component(props) {
19 const $ = React.unstable_useMemoCache(1);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md
+1
@@ -21,6 +21,7 @@ function foo(a) {
21 ## Code
22
23 ```javascript
24 +import * as React from "react";
25 function foo(a) {
26 const $ = React.unstable_useMemoCache(2);
27 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md
+1
@@ -19,6 +19,7 @@ function foo(a) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(a) {
24 const $ = React.unstable_useMemoCache(4);
25 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md
+1
@@ -20,6 +20,7 @@ function foo(a) {
20 ## Code
21
22 ```javascript
23 +import * as React from "react";
24 function foo(a) {
25 const $ = React.unstable_useMemoCache(2);
26 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md
+1
@@ -20,6 +20,7 @@ function foo(a) {
20 ## Code
21
22 ```javascript
23 +import * as React from "react";
24 function foo(a) {
25 const $ = React.unstable_useMemoCache(3);
26 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md
+1
@@ -18,6 +18,7 @@ function foo() {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo() {
23 const $ = React.unstable_useMemoCache(1);
24 let y;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-call.expect.md
+1
@@ -14,6 +14,7 @@ function foo() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function foo() {
19 const $ = React.unstable_useMemoCache(1);
20 let y;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-2.expect.md
+1
@@ -15,6 +15,7 @@ function foo() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function foo() {
20 const $ = React.unstable_useMemoCache(1);
21 let y;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-alias.expect.md
+1
@@ -18,6 +18,7 @@ function foo() {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo() {
23 const $ = React.unstable_useMemoCache(1);
24 let y;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate.expect.md
+1
@@ -15,6 +15,7 @@ function foo() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function foo() {
20 const $ = React.unstable_useMemoCache(1);
21 let y;
compiler/forget/src/__tests__/fixtures/compiler/ssa-property.expect.md
+1
@@ -14,6 +14,7 @@ function foo() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function foo() {
19 const $ = React.unstable_useMemoCache(2);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-reassign-in-rval.expect.md
+1 -1
@@ -14,7 +14,7 @@ function Component() {
14 ## Code
15
16 ```javascript
17 -// Forget should call the original x (x = foo()) to compute result
17 +import * as React from "react"; // Forget should call the original x (x = foo()) to compute result
18 function Component() {
19 const $ = React.unstable_useMemoCache(3);
20 let t0;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md
+1
@@ -18,6 +18,7 @@ function foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(props) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md
+1
@@ -17,6 +17,7 @@ function foo(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function foo(props) {
22 const $ = React.unstable_useMemoCache(4);
23 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md
+1
@@ -16,6 +16,7 @@ function foo(props) {
16 ## Code
17
18 ```javascript
19 +import * as React from "react";
20 function foo(props) {
21 const $ = React.unstable_useMemoCache(2);
22 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md
+1
@@ -15,6 +15,7 @@ function foo(props) {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function foo(props) {
20 const $ = React.unstable_useMemoCache(4);
21 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md
+1
@@ -18,6 +18,7 @@ function foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(props) {
23 const $ = React.unstable_useMemoCache(2);
24 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md
+1
@@ -17,6 +17,7 @@ function foo(props) {
17 ## Code
18
19 ```javascript
20 +import * as React from "react";
21 function foo(props) {
22 const $ = React.unstable_useMemoCache(4);
23 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md
+1
@@ -23,6 +23,7 @@ function foo(props) {
23 ## Code
24
25 ```javascript
26 +import * as React from "react";
27 function foo(props) {
28 const $ = React.unstable_useMemoCache(2);
29 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md
+1
@@ -19,6 +19,7 @@ function foo(props) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(props) {
24 const $ = React.unstable_useMemoCache(2);
25 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md
+1
@@ -18,6 +18,7 @@ function foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(props) {
23 const $ = React.unstable_useMemoCache(4);
24 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md
+1
@@ -19,6 +19,7 @@ function foo(props) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function foo(props) {
24 const $ = React.unstable_useMemoCache(2);
25 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md
+1
@@ -18,6 +18,7 @@ function foo(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function foo(props) {
23 const $ = React.unstable_useMemoCache(4);
24 const c_0 = $[0] !== props.bar;
compiler/forget/src/__tests__/fixtures/compiler/store-via-call.expect.md
+1
@@ -14,6 +14,7 @@ function foo() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function foo() {
19 const $ = React.unstable_useMemoCache(1);
20 let x;
compiler/forget/src/__tests__/fixtures/compiler/store-via-new.expect.md
+1
@@ -14,6 +14,7 @@ function Foo() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function Foo() {
19 const $ = React.unstable_useMemoCache(1);
20 let x;
compiler/forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md
+1
@@ -31,6 +31,7 @@ function Component(props) {
31 ## Code
32
33 ```javascript
34 +import * as React from "react";
35 function Component(props) {
36 const $ = React.unstable_useMemoCache(9);
37 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/switch.expect.md
+1
@@ -26,6 +26,7 @@ function Component(props) {
26 ## Code
27
28 ```javascript
29 +import * as React from "react";
30 function Component(props) {
31 const $ = React.unstable_useMemoCache(8);
32 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/tagged-template-literal.expect.md
+1
@@ -24,6 +24,7 @@ function component() {
24 ## Code
25
26 ```javascript
27 +import * as React from "react";
28 function component() {
29 const $ = React.unstable_useMemoCache(1);
30 let t0;
compiler/forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md
+1
@@ -13,6 +13,7 @@ function component(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component(props) {
18 const $ = React.unstable_useMemoCache(2);
19 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/timers.expect.md
+1
@@ -18,6 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(2);
24 const start = performance.now();
compiler/forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md
+1 -1
@@ -16,7 +16,7 @@ function Component(props) {
16 ## Code
17
18 ```javascript
19 -// @flow
19 +import * as React from "react"; // @flow
20 type Foo = { bar: string };
21 function Component(props) {
22 const $ = React.unstable_useMemoCache(2);
compiler/forget/src/__tests__/fixtures/compiler/type-field-load.expect.md
+1
@@ -13,6 +13,7 @@ function component() {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function component() {
18 const $ = React.unstable_useMemoCache(1);
19 let t0;
compiler/forget/src/__tests__/fixtures/compiler/type-test-field-load-binary-op.expect.md
+1
@@ -19,6 +19,7 @@ function component() {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component() {
24 const $ = React.unstable_useMemoCache(3);
25 let t0;
compiler/forget/src/__tests__/fixtures/compiler/type-test-field-store.expect.md
+1
@@ -15,6 +15,7 @@ function component() {
15 ## Code
16
17 ```javascript
18 +import * as React from "react";
19 function component() {
20 const $ = React.unstable_useMemoCache(2);
21 let x;
compiler/forget/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md
+1
@@ -22,6 +22,7 @@ function component() {
22 ## Code
23
24 ```javascript
25 +import * as React from "react";
26 function component() {
27 const $ = React.unstable_useMemoCache(3);
28 let t0;
compiler/forget/src/__tests__/fixtures/compiler/type-test-return-type-inference.expect.md
+1
@@ -18,6 +18,7 @@ function component() {
18 ## Code
19
20 ```javascript
21 +import * as React from "react";
22 function component() {
23 const $ = React.unstable_useMemoCache(1);
24 const x = foo();
compiler/forget/src/__tests__/fixtures/compiler/unary-expr.expect.md
+1
@@ -19,6 +19,7 @@ function component(a) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function component(a) {
24 const $ = React.unstable_useMemoCache(8);
25 const t = { t: a };
compiler/forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md
+1
@@ -13,6 +13,7 @@ function Foo(props) {
13 ## Code
14
15 ```javascript
16 +import * as React from "react";
17 function Foo(props) {
18 const $ = React.unstable_useMemoCache(2);
19 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/update-expression.expect.md
+1
@@ -14,6 +14,7 @@ function foo(props) {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function foo(props) {
19 const $ = React.unstable_useMemoCache(4);
20 let x = props.x;
compiler/forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md
+1
@@ -14,6 +14,7 @@ function component() {
14 ## Code
15
16 ```javascript
17 +import * as React from "react";
18 function component() {
19 const $ = React.unstable_useMemoCache(5);
20 const [count, setCount] = useState(0);
compiler/forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md
+1
@@ -24,6 +24,7 @@ function Component(props) {
24 ## Code
25
26 ```javascript
27 +import * as React from "react";
28 function Component(props) {
29 const $ = React.unstable_useMemoCache(7);
30 const dispatch = useDispatch();
compiler/forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md
+1
@@ -30,6 +30,7 @@ function Component(props) {
30 ## Code
31
32 ```javascript
33 +import * as React from "react";
34 function Component(props) {
35 const $ = React.unstable_useMemoCache(3);
36 const item = useMutable(props.itemId);
compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 -// @inlineUseMemo
21 +import * as React from "react"; // @inlineUseMemo
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(4);
24 let t17 = undefined;
compiler/forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component(props) {
18 ## Code
19
20 ```javascript
21 -// @inlineUseMemo
21 +import * as React from "react"; // @inlineUseMemo
22 function Component(props) {
23 const $ = React.unstable_useMemoCache(10);
24 const c_0 = $[0] !== props.a;
compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md
+1 -1
@@ -17,7 +17,7 @@ function component(a, b) {
17 ## Code
18
19 ```javascript
20 -// @inlineUseMemo
20 +import * as React from "react"; // @inlineUseMemo
21 function component(a, b) {
22 const $ = React.unstable_useMemoCache(2);
23 let t14 = undefined;
compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md
+1 -1
@@ -23,7 +23,7 @@ function Component(props) {
23 ## Code
24
25 ```javascript
26 -// @inlineUseMemo
26 +import * as React from "react"; // @inlineUseMemo
27 function Component(props) {
28 const $ = React.unstable_useMemoCache(2);
29 const c_0 = $[0] !== props;
compiler/forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md
+1 -1
@@ -13,7 +13,7 @@ function component(a) {
13 ## Code
14
15 ```javascript
16 -// @inlineUseMemo
16 +import * as React from "react"; // @inlineUseMemo
17 function component(a) {
18 const $ = React.unstable_useMemoCache(4);
19 const c_0 = $[0] !== a;
compiler/forget/src/__tests__/fixtures/disableMemoizeJsxElements/Component.expect.md
+1
@@ -19,6 +19,7 @@ function Component(props) {
19 ## Code
20
21 ```javascript
22 +import * as React from "react";
23 function Component(props) {
24 const $ = React.unstable_useMemoCache(2);
25 const [name, setName] = useState(null);