[compiler] @enablePreserveExistingMemoizationGuarantees on by default

This enables `@enablePreserveExistingMemoizationGuarantees` by default. As of the previous PR (#34503), this mode now enables the following behaviors:

- Treating variables referenced within a `useMemo()` or `useCallback()` as "frozen" (immutable) as of the start of the call. Ie, the compiler will assume that the values you reference are not mutated by the body of the useMemo, not are they mutated later. Directly modifying them (eg `var.property = true`) will be an error.
- Similarly, the results of the useMemo/useCallback are treated as frozen (immutable) after the call.

These two rules match the behavior for other hooks: this means that developers will see similar behavior to swapping out `useMemo()` for a custom `useMyMemo()` wrapper/alias.

Additionally, as of #34503 the compiler uses information from the manual dependencies to know which variables are non-nullable. Even if a useMemo block conditionally accesses a nested property — `if (cond) { log(x.y.z) }` — where the compiler would not usually know that `x` is non-nullable, if the user specifies `x.y.z` as a manual dependency then the compiler knows that `x` and `x.y` are non-nullable and can infer a more precise dependency.

Finally, this mode also ensures that we always memoize function calls that return primitives. See #34343 for more details.

For now, I've explicitly opted out of this feature in all test fixtures where the behavior changed.
This commit is contained in:
Joe Savona
2025-10-02 09:53:51 -07:00
parent 57d5a59748
commit ae3444675f
103 changed files with 138 additions and 79 deletions
@@ -210,7 +210,7 @@ export const EnvironmentConfigSchema = z.object({
* that if a useEffect or useCallback references a function value, that function value will be
* considered frozen, and in turn all of its referenced variables will be considered frozen as well.
*/
enablePreserveExistingMemoizationGuarantees: z.boolean().default(false),
enablePreserveExistingMemoizationGuarantees: z.boolean().default(true),
/**
* Validates that all useMemo/useCallback values are also memoized by Forget. This mode can be
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
// bar(props.b) is an allocating expression that produces a primitive, which means
// that Forget should memoize it.
// Correctness:
@@ -16,7 +17,8 @@ function AllocatingPrimitiveAsDep(props) {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // bar(props.b) is an allocating expression that produces a primitive, which means
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
// bar(props.b) is an allocating expression that produces a primitive, which means
// that Forget should memoize it.
// Correctness:
// - y depends on either bar(props.b) or bar(props.b) + 1
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
// bar(props.b) is an allocating expression that produces a primitive, which means
// that Forget should memoize it.
// Correctness:
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
const someGlobal = {value: 0};
@@ -32,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
const someGlobal = { value: 0 };
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
const someGlobal = {value: 0};
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
let a = foo();
// freeze `a` so we know the next line cannot mutate it
@@ -17,7 +18,7 @@ function Component(props) {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const $ = _c(2);
const a = foo();
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
let a = foo();
// freeze `a` so we know the next line cannot mutate it
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {Stringify, identity} from 'shared-runtime';
function foo() {
@@ -64,7 +65,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { Stringify, identity } from "shared-runtime";
function foo() {
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {Stringify, identity} from 'shared-runtime';
function foo() {
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {Stringify} from 'shared-runtime';
@@ -25,7 +26,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import { Stringify } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function foo(props) {
let x, y;
({x, y} = {x: props.a, y: props.b});
@@ -21,6 +22,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function foo(props) {
let x;
let y;
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
function foo(props) {
let x, y;
({x, y} = {x: props.a, y: props.b});
@@ -2,7 +2,7 @@
## Input
```javascript
// @flow @enableNewMutationAliasingModel
// @flow @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
/**
* This hook returns a function that when called with an input object,
* will return the result of mapping that input with the supplied map
@@ -1,4 +1,4 @@
// @flow @enableNewMutationAliasingModel
// @flow @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
/**
* This hook returns a function that when called with an input object,
* will return the result of mapping that input with the supplied map
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
/**
* Repro from https://github.com/facebook/react/issues/34262
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
/**
* Repro from https://github.com/facebook/react/issues/34262
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {identity, Stringify, useHook} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {identity, Stringify, useHook} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @flow @validatePreserveExistingMemoizationGuarantees
// @flow @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {logValue, useFragment, useHook, typedLog} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @flow @validatePreserveExistingMemoizationGuarantees
// @flow @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {logValue, useFragment, useHook, typedLog} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @flow @validatePreserveExistingMemoizationGuarantees
// @flow @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useFragment} from 'react-relay';
import LogEvent from 'LogEvent';
import {useCallback, useMemo} from 'react';
@@ -1,4 +1,4 @@
// @flow @validatePreserveExistingMemoizationGuarantees
// @flow @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useFragment} from 'react-relay';
import LogEvent from 'LogEvent';
import {useCallback, useMemo} from 'react';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {ValidateMemoization, useHook} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {ValidateMemoization, useHook} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {makeObject_Primitives, Stringify} from 'shared-runtime';
function Component(props) {
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {makeObject_Primitives, Stringify} from 'shared-runtime';
function Component(props) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {makeObject_Primitives, Stringify} from 'shared-runtime';
function Component(props) {
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {makeObject_Primitives, Stringify} from 'shared-runtime';
function Component(props) {
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo, useState} from 'react';
import {ValidateMemoization} from 'shared-runtime';
@@ -28,7 +29,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c2 } from "react/compiler-runtime";
import { c as _c2 } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo, useState } from "react";
import { ValidateMemoization } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo, useState} from 'react';
import {ValidateMemoization} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import fbt from 'fbt';
/**
@@ -35,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import fbt from "fbt";
/**
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import fbt from 'fbt';
/**
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
const {identity, mutate} = require('shared-runtime');
function Component(props) {
@@ -24,6 +25,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
const { identity, mutate } = require("shared-runtime");
function Component(props) {
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
const {identity, mutate} = require('shared-runtime');
function Component(props) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @hookPattern:".*\b(use[^$]+)$"
// @hookPattern:".*\b(use[^$]+)$" @enablePreserveExistingMemoizationGuarantees:false
import * as React from 'react';
import {makeArray, useHook} from 'shared-runtime';
@@ -36,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @hookPattern:".*\b(use[^$]+)$"
import { c as _c } from "react/compiler-runtime"; // @hookPattern:".*\b(use[^$]+)$" @enablePreserveExistingMemoizationGuarantees:false
import * as React from "react";
import { makeArray, useHook } from "shared-runtime";
@@ -1,4 +1,4 @@
// @hookPattern:".*\b(use[^$]+)$"
// @hookPattern:".*\b(use[^$]+)$" @enablePreserveExistingMemoizationGuarantees:false
import * as React from 'react';
import {makeArray, useHook} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @debug
// @debug @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x[props.value];
@@ -14,7 +14,7 @@ function Component(props) {
## Code
```javascript
// @debug
// @debug @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x[props.value];
@@ -1,4 +1,4 @@
// @debug
// @debug @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x[props.value];
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x.value;
@@ -13,6 +14,7 @@ function Component(props) {
## Code
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x.value;
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
function Component(props) {
const x = makeObject();
const y = delete x.value;
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees @enableNewMutationAliasingModel
// @validatePreserveExistingMemoizationGuarantees @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {makeArray} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees @enableNewMutationAliasingModel
// @validatePreserveExistingMemoizationGuarantees @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {makeArray} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, ValidateMemoization} from 'shared-runtime';
@@ -32,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import { identity, ValidateMemoization } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, ValidateMemoization} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, ValidateMemoization} from 'shared-runtime';
@@ -29,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import { identity, ValidateMemoization } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, ValidateMemoization} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
mutate,
@@ -49,7 +50,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
mutate,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
mutate,
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -41,7 +42,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
typedCapture,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -42,7 +43,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
typedCapture,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -40,7 +41,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
typedCapture,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -36,7 +37,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
typedCapture,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -40,7 +41,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import {
typedCapture,
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {
typedCapture,
@@ -2,7 +2,7 @@
## Input
```javascript
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -36,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import { useCallback } from "react";
import { Stringify } from "shared-runtime";
@@ -1,4 +1,4 @@
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import { useCallback } from "react";
import { Stringify } from "shared-runtime";
@@ -1,4 +1,4 @@
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
function useFoo(arr1, arr2) {
@@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
function useFoo(arr1, arr2) {
@@ -1,4 +1,4 @@
// @enableNewMutationAliasingModel
// @enableNewMutationAliasingModel @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
function useFoo(arr1, arr2) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
function Component({propA, propB}) {
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
function Component({propA, propB}) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {identity, mutate} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {identity, mutate} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {makeArray} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {makeArray} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
function Component({propA, propB}) {
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
function Component({propA, propB}) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {mutate} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {mutate} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {mutate} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {mutate} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, mutate} from 'shared-runtime';
@@ -1,4 +1,4 @@
// @validatePreserveExistingMemoizationGuarantees
// @validatePreserveExistingMemoizationGuarantees @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {identity, mutate} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -35,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useCallback } from "react";
import { Stringify } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -30,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useCallback } from "react";
import { Stringify } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
function useFoo(arr1, arr2) {
@@ -26,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
function useFoo(arr1, arr2) {
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
function useFoo(arr1, arr2) {
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {Stringify} from 'shared-runtime';
@@ -35,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import { Stringify } from "shared-runtime";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {Stringify} from 'shared-runtime';
@@ -2,7 +2,7 @@
## Input
```javascript
// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions @enablePreserveExistingMemoizationGuarantees:false
function Component() {
const items = useItems();
const filteredItems = useMemo(
@@ -37,7 +37,7 @@ function Component() {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
import { c as _c } from "react/compiler-runtime"; // @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions @enablePreserveExistingMemoizationGuarantees:false
function Component() {
const $ = _c(6);
const items = useItems();
@@ -1,4 +1,4 @@
// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions @enablePreserveExistingMemoizationGuarantees:false
function Component() {
const items = useItems();
const filteredItems = useMemo(
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {Stringify, identity, makeArray, toJSON} from 'shared-runtime';
import {useMemo} from 'react';
@@ -40,7 +41,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { Stringify, identity, makeArray, toJSON } from "shared-runtime";
import { useMemo } from "react";
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
import {Stringify, identity, makeArray, toJSON} from 'shared-runtime';
import {useMemo} from 'react';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
const THEME_MAP: ReadonlyMap<string, string> = new Map([
['default', 'light'],
['dark', 'dark'],
@@ -21,7 +22,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
const THEME_MAP: ReadonlyMap<string, string> = new Map([
["default", "light"],
["dark", "dark"],
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
const THEME_MAP: ReadonlyMap<string, string> = new Map([
['default', 'light'],
['dark', 'dark'],
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
function component(a) {
let t = {t: a};
let z = +t.t;
@@ -25,7 +26,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
function component(a) {
const $ = _c(8);
const t = { t: a };
@@ -1,3 +1,4 @@
// @enablePreserveExistingMemoizationGuarantees:false
function component(a) {
let t = {t: a};
let z = +t.t;
@@ -2,7 +2,7 @@
## Input
```javascript
// @validateNoSetStateInRender:false
// @validateNoSetStateInRender:false @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {makeArray} from 'shared-runtime';
@@ -21,7 +21,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @validateNoSetStateInRender:false
import { c as _c } from "react/compiler-runtime"; // @validateNoSetStateInRender:false @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
import { makeArray } from "shared-runtime";
@@ -1,4 +1,4 @@
// @validateNoSetStateInRender:false
// @validateNoSetStateInRender:false @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
import {makeArray} from 'shared-runtime';
@@ -2,6 +2,7 @@
## Input
```javascript
// @enablePreserveExistingMemoizationGuarantees:false
import {useMemo} from 'react';
function Component(props) {
return (
@@ -21,7 +22,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees:false
import { useMemo } from "react";
function Component(props) {
const $ = _c(2);

Some files were not shown because too many files have changed in this diff Show More