diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.expect.md index 82afa9c51de94..aeae54128b03a 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.expect.md @@ -19,15 +19,17 @@ function Component() { ); } -function cx(obj) { - const classes = []; - for (const [key, value] of Object.entries(obj)) { - if (value) { - classes.push(key); +const cx = { + foo(obj) { + const classes = []; + for (const [key, value] of Object.entries(obj)) { + if (value) { + classes.push(key); + } } - } - return classes.join(' '); -} + return classes.join(' '); + }, +}; function useTheme() { return { @@ -71,15 +73,17 @@ function Component() { return t1; } -function cx(obj) { - const classes = []; - for (const [key, value] of Object.entries(obj)) { - if (value) { - classes.push(key); +const cx = { + foo(obj) { + const classes = []; + for (const [key, value] of Object.entries(obj)) { + if (value) { + classes.push(key); + } } - } - return classes.join(" "); -} + return classes.join(" "); + }, +}; function useTheme() { return { @@ -97,4 +101,4 @@ export const FIXTURE_ENTRYPOINT = { ``` ### Eval output -(kind: exception) cx.foo is not a function \ No newline at end of file +(kind: ok)
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.js index c0eb2f2dcd01c..fe7abb7cdf6ac 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-isms/repro-cx-namespace-assigned-to-temporary.js @@ -15,15 +15,17 @@ function Component() { ); } -function cx(obj) { - const classes = []; - for (const [key, value] of Object.entries(obj)) { - if (value) { - classes.push(key); +const cx = { + foo(obj) { + const classes = []; + for (const [key, value] of Object.entries(obj)) { + if (value) { + classes.push(key); + } } - } - return classes.join(' '); -} + return classes.join(' '); + }, +}; function useTheme() { return { diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md index 7649bfd1fa574..dcade9000aa8e 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md @@ -4,6 +4,8 @@ ```javascript import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime'; +function mutate(_: unknown) {} + /** * There are three values with their own scopes in this fixture. * - arr, whose mutable range extends to the `mutate(...)` call @@ -45,6 +47,8 @@ export const FIXTURE_ENTRYPOINT = { import { c as _c } from "react/compiler-runtime"; import { CONST_TRUE, identity, shallowCopy } from "shared-runtime"; +function mutate(_) {} + /** * There are three values with their own scopes in this fixture. * - arr, whose mutable range extends to the `mutate(...)` call @@ -91,4 +95,4 @@ export const FIXTURE_ENTRYPOINT = { ``` ### Eval output -(kind: exception) mutate is not defined \ No newline at end of file +(kind: ok) \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.ts b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.ts index 72a5fa2e1b3bb..fd4452bebbd86 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.ts @@ -1,5 +1,7 @@ import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime'; +function mutate(_: unknown) {} + /** * There are three values with their own scopes in this fixture. * - arr, whose mutable range extends to the `mutate(...)` call diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.expect.md index 184779869e9a3..687d9565ba88c 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.expect.md @@ -6,6 +6,8 @@ import {useCallback} from 'react'; import {identity, useIdentity} from 'shared-runtime'; +function mutate(_: unknown) {} + /** * Repro showing a manual memo whose declaration (useCallback's 1st argument) * is memoized, but not its dependency (x). In this case, `x`'s scope is pruned @@ -33,6 +35,8 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe import { useCallback } from "react"; import { identity, useIdentity } from "shared-runtime"; +function mutate(_) {} + /** * Repro showing a manual memo whose declaration (useCallback's 1st argument) * is memoized, but not its dependency (x). In this case, `x`'s scope is pruned @@ -62,4 +66,4 @@ export const FIXTURE_ENTRYPOINT = { ``` ### Eval output -(kind: exception) mutate is not defined \ No newline at end of file +(kind: ok) "[[ function params=0 ]]" \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.ts b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.ts index 8fdd74ea571a2..23de8c2c259a9 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-dep-scope-pruned.ts @@ -2,6 +2,8 @@ import {useCallback} from 'react'; import {identity, useIdentity} from 'shared-runtime'; +function mutate(_: unknown) {} + /** * Repro showing a manual memo whose declaration (useCallback's 1st argument) * is memoized, but not its dependency (x). In this case, `x`'s scope is pruned diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.expect.md index cd31d1fb0bb8a..01161d0941e5f 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.expect.md @@ -4,6 +4,8 @@ ```javascript import {identity, makeObject_Primitives} from 'shared-runtime'; +function useHook() {} + function useTest({cond}) { const val = makeObject_Primitives(); @@ -31,6 +33,8 @@ export const FIXTURE_ENTRYPOINT = { import { c as _c } from "react/compiler-runtime"; import { identity, makeObject_Primitives } from "shared-runtime"; +function useHook() {} + function useTest(t0) { const $ = _c(3); const { cond } = t0; @@ -64,4 +68,4 @@ export const FIXTURE_ENTRYPOINT = { ``` ### Eval output -(kind: exception) useHook is not defined \ No newline at end of file +(kind: ok) {"a":0,"b":"value1","c":true} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.ts b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.ts index e1c62a3cf1384..017ea326b406a 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-allocating-ternary-test-instruction-scope.ts @@ -1,5 +1,7 @@ import {identity, makeObject_Primitives} from 'shared-runtime'; +function useHook() {} + function useTest({cond}) { const val = makeObject_Primitives(); diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md index 59563ea67fa8f..002bc6ee89bef 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md @@ -2,7 +2,7 @@ ## Input ```javascript -import {makeObject_Primitives} from 'shared-runtime'; +import {makeObject_Primitives, Stringify} from 'shared-runtime'; function Component(props) { let useFeature = makeObject_Primitives(); @@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = { ```javascript import { c as _c } from "react/compiler-runtime"; -import { makeObject_Primitives } from "shared-runtime"; +import { makeObject_Primitives, Stringify } from "shared-runtime"; function Component(props) { const $ = _c(2); @@ -75,4 +75,4 @@ export const FIXTURE_ENTRYPOINT = { ``` ### Eval output -(kind: exception) Stringify is not defined \ No newline at end of file +(kind: ok)
{"val":{"a":0,"b":"value1","c":true},"children":[2,"[[ cyclic ref *1 ]]",null]}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.js index 246abee218802..8715db07ece6d 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.js @@ -1,4 +1,4 @@ -import {makeObject_Primitives} from 'shared-runtime'; +import {makeObject_Primitives, Stringify} from 'shared-runtime'; function Component(props) { let useFeature = makeObject_Primitives();