[compiler] Update diagnostics for ValidatePreservedManualMemoization (#33759)
Uses the new diagnostic infrastructure for this validation, which lets us provide a more targeted message on the text that we highlight (eg "This dependency may be mutated later") separately from the overall error message. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33759). * #33981 * #33777 * #33767 * #33765 * #33760 * __->__ #33759 * #33758
Joseph Savona committed
Jul 24, 2025 at 15:39 UTC
48bc166428404c948315d98d02fe69533956e319
33 files changed
+191
-209
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidatePreservedManualMemoization.ts
+70
-40
@@ -5,7 +5,11 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import {CompilerError, ErrorSeverity} from '../CompilerError';
8
+import {
9
+ CompilerDiagnostic,
10
+ CompilerError,
11
+ ErrorSeverity,
12
+} from '../CompilerError';
13
import {
14
DeclarationId,
15
Effect,
@@ -275,27 +279,37 @@ function validateInferredDep(
279
errorDiagnostic = merge(errorDiagnostic ?? compareResult, compareResult);
280
}
281
}
278
- errorState.push({
279
- severity: ErrorSeverity.CannotPreserveMemoization,
280
- reason:
281
- 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected',
282
- description:
283
- DEBUG ||
284
- // If the dependency is a named variable then we can report it. Otherwise only print in debug mode
285
- (dep.identifier.name != null && dep.identifier.name.kind === 'named')
286
- ? `The inferred dependency was \`${prettyPrintScopeDependency(
287
- dep,
288
- )}\`, but the source dependencies were [${validDepsInMemoBlock
289
- .map(dep => printManualMemoDependency(dep, true))
290
- .join(', ')}]. ${
291
- errorDiagnostic
292
- ? getCompareDependencyResultDescription(errorDiagnostic)
293
- : 'Inferred dependency not present in source'
294
- }`
295
- : null,
296
- loc: memoLocation,
297
- suggestions: null,
298
- });
282
+ errorState.pushDiagnostic(
283
+ CompilerDiagnostic.create({
284
+ severity: ErrorSeverity.CannotPreserveMemoization,
285
+ category:
286
+ 'Compilation skipped because existing memoization could not be preserved',
287
+ description: [
288
+ 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. ',
289
+ 'The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. ',
290
+ DEBUG ||
291
+ // If the dependency is a named variable then we can report it. Otherwise only print in debug mode
292
+ (dep.identifier.name != null && dep.identifier.name.kind === 'named')
293
+ ? `The inferred dependency was \`${prettyPrintScopeDependency(
294
+ dep,
295
+ )}\`, but the source dependencies were [${validDepsInMemoBlock
296
+ .map(dep => printManualMemoDependency(dep, true))
297
+ .join(', ')}]. ${
298
+ errorDiagnostic
299
+ ? getCompareDependencyResultDescription(errorDiagnostic)
300
+ : 'Inferred dependency not present in source'
301
+ }.`
302
+ : '',
303
+ ]
304
+ .join('')
305
+ .trim(),
306
+ suggestions: null,
307
+ }).withDetail({
308
+ kind: 'error',
309
+ loc: memoLocation,
310
+ message: 'Could not preserve existing manual memoization',
311
+ }),
312
+ );
313
}
314
315
class Visitor extends ReactiveFunctionVisitor<VisitorState> {
@@ -519,14 +533,21 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
533
!this.scopes.has(identifier.scope.id) &&
534
!this.prunedScopes.has(identifier.scope.id)
535
) {
522
- state.errors.push({
523
- reason:
524
- 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly',
525
- description: null,
526
- severity: ErrorSeverity.CannotPreserveMemoization,
527
- loc,
528
- suggestions: null,
529
- });
536
+ state.errors.pushDiagnostic(
537
+ CompilerDiagnostic.create({
538
+ severity: ErrorSeverity.CannotPreserveMemoization,
539
+ category:
540
+ 'Compilation skipped because existing memoization could not be preserved',
541
+ description: [
542
+ 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. ',
543
+ 'This dependency may be mutated later, which could cause the value to change unexpectedly.',
544
+ ].join(''),
545
+ }).withDetail({
546
+ kind: 'error',
547
+ loc,
548
+ message: 'This dependency may be modified later',
549
+ }),
550
+ );
551
}
552
}
553
}
@@ -560,16 +581,25 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
581
582
for (const identifier of decls) {
583
if (isUnmemoized(identifier, this.scopes)) {
563
- state.errors.push({
564
- reason:
565
- 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.',
566
- description: DEBUG
567
- ? `${printIdentifier(identifier)} was not memoized`
568
- : null,
569
- severity: ErrorSeverity.CannotPreserveMemoization,
570
- loc,
571
- suggestions: null,
572
- });
584
+ state.errors.pushDiagnostic(
585
+ CompilerDiagnostic.create({
586
+ severity: ErrorSeverity.CannotPreserveMemoization,
587
+ category:
588
+ 'Compilation skipped because existing memoization could not be preserved',
589
+ description: [
590
+ 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output. ',
591
+ DEBUG
592
+ ? `${printIdentifier(identifier)} was not memoized.`
593
+ : '',
594
+ ]
595
+ .join('')
596
+ .trim(),
597
+ }).withDetail({
598
+ kind: 'error',
599
+ loc,
600
+ message: 'Could not preserve existing memoization',
601
+ }),
602
+ );
603
}
604
}
605
}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hoist-optional-member-expression-with-conditional-optional.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component(props) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
31
32
error.hoist-optional-member-expression-with-conditional-optional.ts:4:23
33
2 | import {ValidateMemoization} from 'shared-runtime';
@@ -47,12 +47,10 @@ error.hoist-optional-member-expression-with-conditional-optional.ts:4:23
47
> 10 | return x;
48
| ^^^^^^^^^^^^^^^^^
49
> 11 | }, [props?.items, props.cond]);
50
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
50
+ | ^^^^ Could not preserve existing manual memoization
51
12 | return (
52
13 | <ValidateMemoization inputs={[props?.items, props.cond]} output={data} />
53
14 | );
54
-
55
-
54
```
55
56
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hoist-optional-member-expression-with-conditional.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component(props) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
31
32
error.hoist-optional-member-expression-with-conditional.ts:4:23
33
2 | import {ValidateMemoization} from 'shared-runtime';
@@ -47,12 +47,10 @@ error.hoist-optional-member-expression-with-conditional.ts:4:23
47
> 10 | return x;
48
| ^^^^^^^^^^^^^^^^^
49
> 11 | }, [props?.items, props.cond]);
50
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
50
+ | ^^^^ Could not preserve existing manual memoization
51
12 | return (
52
13 | <ValidateMemoization inputs={[props?.items, props.cond]} output={data} />
53
14 | );
54
-
55
-
54
```
55
56
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-optional-member-expression-as-memo-dep-non-optional-in-body.expect.md
+3
-5
@@ -19,9 +19,9 @@ function Component(props) {
19
20
```
21
Found 1 error:
22
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
22
+Memoization: Compilation skipped because existing memoization could not be preserved
23
24
-The inferred dependency was `props.items.edges.nodes`, but the source dependencies were [props.items?.edges?.nodes]. Inferred different dependency than source.
24
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `props.items.edges.nodes`, but the source dependencies were [props.items?.edges?.nodes]. Inferred different dependency than source.
25
26
error.invalid-optional-member-expression-as-memo-dep-non-optional-in-body.ts:3:23
27
1 | // @validatePreserveExistingMemoizationGuarantees
@@ -35,12 +35,10 @@ error.invalid-optional-member-expression-as-memo-dep-non-optional-in-body.ts:3:2
35
> 6 | // deps are optional
36
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37
> 7 | }, [props.items?.edges?.nodes]);
38
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
38
+ | ^^^^ Could not preserve existing manual memoization
39
8 | return <Foo data={data} />;
40
9 | }
41
10 |
42
-
43
-
42
```
43
44
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.ref-like-name-not-Ref.expect.md
+3
-5
@@ -32,9 +32,9 @@ export const FIXTURE_ENTRYPOINT = {
32
33
```
34
Found 1 error:
35
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
35
+Memoization: Compilation skipped because existing memoization could not be preserved
36
37
-The inferred dependency was `Ref.current`, but the source dependencies were []. Inferred dependency not present in source.
37
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `Ref.current`, but the source dependencies were []. Inferred dependency not present in source.
38
39
error.ref-like-name-not-Ref.ts:11:30
40
9 | const Ref = useCustomRef();
@@ -44,12 +44,10 @@ error.ref-like-name-not-Ref.ts:11:30
44
> 12 | Ref.current?.click();
45
| ^^^^^^^^^^^^^^^^^^^^^^^^^
46
> 13 | }, []);
47
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
47
+ | ^^^^ Could not preserve existing manual memoization
48
14 |
49
15 | return <button onClick={onClick} />;
50
16 | }
51
-
52
-
51
```
52
53
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.ref-like-name-not-a-ref.expect.md
+3
-5
@@ -32,9 +32,9 @@ export const FIXTURE_ENTRYPOINT = {
32
33
```
34
Found 1 error:
35
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
35
+Memoization: Compilation skipped because existing memoization could not be preserved
36
37
-The inferred dependency was `notaref.current`, but the source dependencies were []. Inferred dependency not present in source.
37
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `notaref.current`, but the source dependencies were []. Inferred dependency not present in source.
38
39
error.ref-like-name-not-a-ref.ts:11:30
40
9 | const notaref = useCustomRef();
@@ -44,12 +44,10 @@ error.ref-like-name-not-a-ref.ts:11:30
44
> 12 | notaref.current?.click();
45
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46
> 13 | }, []);
47
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
47
+ | ^^^^ Could not preserve existing manual memoization
48
14 |
49
15 | return <button onClick={onClick} />;
50
16 | }
51
-
52
-
51
```
52
53
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-missed-memoization-from-capture-in-invoked-function-inferred-as-mutation.expect.md
+4
-4
@@ -43,18 +43,18 @@ component Component() {
43
44
```
45
Found 1 error:
46
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
46
+Memoization: Compilation skipped because existing memoization could not be preserved
47
+
48
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
49
50
undefined:18:20
51
16 | // We infer that getIsEnabled returns a mutable value, such that
52
17 | // isEnabled is mutable
53
> 18 | const isEnabled = useMemo(() => getIsEnabled(), [getIsEnabled]);
52
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
54
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not preserve existing memoization
55
19 |
56
20 | // We then infer getLoggingData as capturing that mutable value,
57
21 | // so any calls to this function are then inferred as extending
56
-
57
-
58
```
59
60
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-missed-memoization-from-inferred-mutation-in-logger.expect.md
+10
-10
@@ -53,7 +53,9 @@ component Component(id) {
53
54
```
55
Found 3 errors:
56
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
56
+Memoization: Compilation skipped because existing memoization could not be preserved
57
+
58
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
59
60
undefined:11:18
61
9 | const [index, setIndex] = useState(0);
@@ -69,25 +71,25 @@ undefined:11:18
71
> 15 | };
72
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
> 16 | }, [index, items]);
72
- | ^^^^^^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
74
+ | ^^^^^^^^^^^^^^^^^^^^^ Could not preserve existing memoization
75
17 |
76
18 | const setCurrentIndex = useCallback(
77
19 | (index: number) => {
78
+Memoization: Compilation skipped because existing memoization could not be preserved
79
77
-
78
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
80
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly.
81
82
undefined:28:12
83
26 | setIndex(index);
84
27 | },
85
> 28 | [index, logData, items]
84
- | ^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
86
+ | ^^^^^^^ This dependency may be modified later
87
29 | );
88
30 |
89
31 | if (prevId !== id) {
90
+Memoization: Compilation skipped because existing memoization could not be preserved
91
89
-
90
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
92
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
93
94
undefined:19:4
95
17 |
@@ -109,12 +111,10 @@ undefined:19:4
111
> 26 | setIndex(index);
112
| ^^^^^^^^^^^^^^^^^^^^^^
113
> 27 | },
112
- | ^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
114
+ | ^^^^^^ Could not preserve existing memoization
115
28 | [index, logData, items]
116
29 | );
117
30 |
116
-
117
-
118
```
119
120
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-unmemoized-callback-captured-in-context-variable.expect.md
+4
-4
@@ -51,18 +51,18 @@ export const FIXTURE_ENTRYPOINT = {
51
52
```
53
Found 1 error:
54
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
54
+Memoization: Compilation skipped because existing memoization could not be preserved
55
+
56
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
57
58
error.todo-repro-unmemoized-callback-captured-in-context-variable.ts:11:12
59
9 | const a = useHook();
60
10 | // Because b is also part of that same mutable range, it can't be memoized either
61
> 11 | const b = useMemo(() => ({}), []);
60
- | ^^^^^^^^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
62
+ | ^^^^^^^^^^^^^^^^^^^^^^^ Could not preserve existing memoization
63
12 |
64
13 | // Conditional assignment without a subsequent mutation normally doesn't create a mutable
65
14 | // range, but in this case we're reassigning a context variable
64
-
65
-
66
```
67
68
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/dynamic-gating-bailout-nopanic.expect.md
+1
-1
@@ -58,7 +58,7 @@ export const FIXTURE_ENTRYPOINT = {
58
## Logs
59
60
```
61
-{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":206},"end":{"line":16,"column":1,"index":433},"filename":"dynamic-gating-bailout-nopanic.ts"},"detail":{"options":{"reason":"React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected","description":"The inferred dependency was `value`, but the source dependencies were []. Inferred dependency not present in source","severity":"CannotPreserveMemoization","suggestions":null,"loc":{"start":{"line":9,"column":31,"index":288},"end":{"line":9,"column":52,"index":309},"filename":"dynamic-gating-bailout-nopanic.ts"}}}}
61
+{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":206},"end":{"line":16,"column":1,"index":433},"filename":"dynamic-gating-bailout-nopanic.ts"},"detail":{"options":{"severity":"CannotPreserveMemoization","category":"Compilation skipped because existing memoization could not be preserved","description":"React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `value`, but the source dependencies were []. Inferred dependency not present in source.","suggestions":null,"details":[{"kind":"error","loc":{"start":{"line":9,"column":31,"index":288},"end":{"line":9,"column":52,"index":309},"filename":"dynamic-gating-bailout-nopanic.ts"},"message":"Could not preserve existing manual memoization"}]}}}
62
```
63
64
### Eval output
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-useCallback-captures-reassigned-context.expect.md
+7
-7
@@ -30,30 +30,30 @@ export const FIXTURE_ENTRYPOINT = {
30
31
```
32
Found 2 errors:
33
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
33
+Memoization: Compilation skipped because existing memoization could not be preserved
34
+
35
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly.
36
37
error.invalid-useCallback-captures-reassigned-context.ts:11:37
38
9 |
39
10 | // makeArray() is captured, but depsList contains [props]
40
> 11 | const cb = useCallback(() => [x], [x]);
39
- | ^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
41
+ | ^ This dependency may be modified later
42
12 |
43
13 | x = makeArray();
44
14 |
45
+Memoization: Compilation skipped because existing memoization could not be preserved
46
44
-
45
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
47
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
48
49
error.invalid-useCallback-captures-reassigned-context.ts:11:25
50
9 |
51
10 | // makeArray() is captured, but depsList contains [props]
52
> 11 | const cb = useCallback(() => [x], [x]);
51
- | ^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
53
+ | ^^^^^^^^^ Could not preserve existing memoization
54
12 |
55
13 | x = makeArray();
56
14 |
55
-
56
-
57
```
58
59
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-dropped-infer-always-invalidating.expect.md
+4
-4
@@ -31,18 +31,18 @@ export const FIXTURE_ENTRYPOINT = {
31
32
```
33
Found 1 error:
34
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
34
+Memoization: Compilation skipped because existing memoization could not be preserved
35
+
36
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
37
38
error.false-positive-useMemo-dropped-infer-always-invalidating.ts:15:9
39
13 | x.push(props);
40
14 |
41
> 15 | return useMemo(() => [x], [x]);
40
- | ^^^^^^^^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
42
+ | ^^^^^^^^^^^^^^^^^^^^^^^ Could not preserve existing memoization
43
16 | }
44
17 |
45
18 | export const FIXTURE_ENTRYPOINT = {
44
-
45
-
46
```
47
48
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-infer-mutate-deps.expect.md
+4
-4
@@ -30,18 +30,18 @@ export const FIXTURE_ENTRYPOINT = {
30
31
```
32
Found 1 error:
33
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
33
+Memoization: Compilation skipped because existing memoization could not be preserved
34
+
35
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly.
36
37
error.false-positive-useMemo-infer-mutate-deps.ts:14:6
38
12 | return useMemo(() => {
39
13 | return identity(val);
40
> 14 | }, [val]);
39
- | ^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
41
+ | ^^^ This dependency may be modified later
42
15 | }
43
16 |
44
17 | export const FIXTURE_ENTRYPOINT = {
43
-
44
-
45
```
46
47
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-overlap-scopes.expect.md
+4
-4
@@ -41,18 +41,18 @@ export const FIXTURE_ENTRYPOINT = {
41
42
```
43
Found 1 error:
44
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
44
+Memoization: Compilation skipped because existing memoization could not be preserved
45
+
46
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly.
47
48
error.false-positive-useMemo-overlap-scopes.ts:23:9
49
21 | const result = useMemo(() => {
50
22 | return [Math.max(x[1], a)];
51
> 23 | }, [a, x]);
50
- | ^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
52
+ | ^ This dependency may be modified later
53
24 | arrayPush(y, 3);
54
25 | return {result, y};
55
26 | }
54
-
55
-
56
```
57
58
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.hoist-useCallback-conditional-access-own-scope.expect.md
+3
-5
@@ -27,9 +27,9 @@ export const FIXTURE_ENTRYPOINT = {
27
28
```
29
Found 1 error:
30
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
30
+Memoization: Compilation skipped because existing memoization could not be preserved
31
32
-The inferred dependency was `propB`, but the source dependencies were [propA, propB.x.y]. Inferred less specific property than source.
32
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB`, but the source dependencies were [propA, propB.x.y]. Inferred less specific property than source.
33
34
error.hoist-useCallback-conditional-access-own-scope.ts:5:21
35
3 |
@@ -47,12 +47,10 @@ error.hoist-useCallback-conditional-access-own-scope.ts:5:21
47
> 10 | }
48
| ^^^^^^^^^^^^^^^^
49
> 11 | }, [propA, propB.x.y]);
50
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
50
+ | ^^^^ Could not preserve existing manual memoization
51
12 | }
52
13 |
53
14 | export const FIXTURE_ENTRYPOINT = {
54
-
55
-
54
```
55
56
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.hoist-useCallback-infer-conditional-value-block.expect.md
+6
-10
@@ -30,9 +30,9 @@ export const FIXTURE_ENTRYPOINT = {
30
31
```
32
Found 2 errors:
33
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
33
+Memoization: Compilation skipped because existing memoization could not be preserved
34
35
-The inferred dependency was `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
35
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
36
37
error.hoist-useCallback-infer-conditional-value-block.ts:6:21
38
4 |
@@ -54,15 +54,13 @@ error.hoist-useCallback-infer-conditional-value-block.ts:6:21
54
> 13 | }
55
| ^^^^^^^^^^^^^^^^^
56
> 14 | }, [propA.a, propB.x.y]);
57
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
57
+ | ^^^^ Could not preserve existing manual memoization
58
15 | }
59
16 |
60
17 | export const FIXTURE_ENTRYPOINT = {
61
+Memoization: Compilation skipped because existing memoization could not be preserved
62
62
-
63
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
64
-
65
-The inferred dependency was `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
63
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
64
65
error.hoist-useCallback-infer-conditional-value-block.ts:6:21
66
4 |
@@ -84,12 +82,10 @@ error.hoist-useCallback-infer-conditional-value-block.ts:6:21
82
> 13 | }
83
| ^^^^^^^^^^^^^^^^^
84
> 14 | }, [propA.a, propB.x.y]);
87
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
85
+ | ^^^^ Could not preserve existing manual memoization
86
15 | }
87
16 |
88
17 | export const FIXTURE_ENTRYPOINT = {
91
-
92
-
89
```
90
91
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.invalid-useCallback-captures-reassigned-context.expect.md
+7
-7
@@ -31,30 +31,30 @@ export const FIXTURE_ENTRYPOINT = {
31
32
```
33
Found 2 errors:
34
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
34
+Memoization: Compilation skipped because existing memoization could not be preserved
35
+
36
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly.
37
38
error.invalid-useCallback-captures-reassigned-context.ts:12:37
39
10 |
40
11 | // makeArray() is captured, but depsList contains [props]
41
> 12 | const cb = useCallback(() => [x], [x]);
40
- | ^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly
42
+ | ^ This dependency may be modified later
43
13 |
44
14 | x = makeArray();
45
15 |
46
+Memoization: Compilation skipped because existing memoization could not be preserved
47
45
-
46
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
48
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
49
50
error.invalid-useCallback-captures-reassigned-context.ts:12:25
51
10 |
52
11 | // makeArray() is captured, but depsList contains [props]
53
> 12 | const cb = useCallback(() => [x], [x]);
52
- | ^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
54
+ | ^^^^^^^^^ Could not preserve existing memoization
55
13 |
56
14 | x = makeArray();
57
15 |
56
-
57
-
58
```
59
60
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.maybe-invalid-useCallback-read-maybeRef.expect.md
+3
-5
@@ -18,9 +18,9 @@ function useHook(maybeRef) {
18
19
```
20
Found 1 error:
21
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
21
+Memoization: Compilation skipped because existing memoization could not be preserved
22
23
-The inferred dependency was `maybeRef.current`, but the source dependencies were [maybeRef]. Differences in ref.current access.
23
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `maybeRef.current`, but the source dependencies were [maybeRef]. Differences in ref.current access.
24
25
error.maybe-invalid-useCallback-read-maybeRef.ts:5:21
26
3 |
@@ -30,11 +30,9 @@ error.maybe-invalid-useCallback-read-maybeRef.ts:5:21
30
> 6 | return [maybeRef.current];
31
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
> 7 | }, [maybeRef]);
33
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
33
+ | ^^^^ Could not preserve existing manual memoization
34
8 | }
35
9 |
36
-
37
-
36
```
37
38
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.maybe-invalid-useMemo-read-maybeRef.expect.md
+3
-5
@@ -18,9 +18,9 @@ function useHook(maybeRef, shouldRead) {
18
19
```
20
Found 1 error:
21
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
21
+Memoization: Compilation skipped because existing memoization could not be preserved
22
23
-The inferred dependency was `maybeRef.current`, but the source dependencies were [shouldRead, maybeRef]. Differences in ref.current access.
23
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `maybeRef.current`, but the source dependencies were [shouldRead, maybeRef]. Differences in ref.current access.
24
25
error.maybe-invalid-useMemo-read-maybeRef.ts:5:17
26
3 |
@@ -30,11 +30,9 @@ error.maybe-invalid-useMemo-read-maybeRef.ts:5:17
30
> 6 | return () => [maybeRef.current];
31
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
> 7 | }, [shouldRead, maybeRef]);
33
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
33
+ | ^^^^ Could not preserve existing manual memoization
34
8 | }
35
9 |
36
-
37
-
36
```
37
38
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.preserve-use-memo-ref-missing-reactive.expect.md
+3
-5
@@ -29,9 +29,9 @@ export const FIXTURE_ENTRYPOINT = {
29
30
```
31
Found 1 error:
32
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
32
+Memoization: Compilation skipped because existing memoization could not be preserved
33
34
-The inferred dependency was `ref`, but the source dependencies were []. Inferred dependency not present in source.
34
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `ref`, but the source dependencies were []. Inferred dependency not present in source.
35
36
error.preserve-use-memo-ref-missing-reactive.ts:9:21
37
7 | const ref = cond ? ref1 : ref2;
@@ -45,12 +45,10 @@ error.preserve-use-memo-ref-missing-reactive.ts:9:21
45
> 12 | }
46
| ^^^^^^^^^^^^^^^^^^^^^^
47
> 13 | }, []);
48
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
48
+ | ^^^^ Could not preserve existing manual memoization
49
14 | }
50
15 |
51
16 | export const FIXTURE_ENTRYPOINT = {
52
-
53
-
52
```
53
54
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.todo-useCallback-captures-invalidating-value.expect.md
+4
-4
@@ -29,18 +29,18 @@ export const FIXTURE_ENTRYPOINT = {
29
30
```
31
Found 1 error:
32
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
32
+Memoization: Compilation skipped because existing memoization could not be preserved
33
+
34
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
35
36
error.todo-useCallback-captures-invalidating-value.ts:13:21
37
11 | x.push(props);
38
12 |
39
> 13 | return useCallback(() => [x], [x]);
38
- | ^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
40
+ | ^^^^^^^^^ Could not preserve existing memoization
41
14 | }
42
15 |
43
16 | export const FIXTURE_ENTRYPOINT = {
42
-
43
-
44
```
45
46
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-aliased-var.expect.md
+3
-5
@@ -20,19 +20,17 @@ function useHook(x) {
20
21
```
22
Found 1 error:
23
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
23
+Memoization: Compilation skipped because existing memoization could not be preserved
24
25
-The inferred dependency was `aliasedX`, but the source dependencies were [x, aliasedProp]. Inferred different dependency than source.
25
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `aliasedX`, but the source dependencies were [x, aliasedProp]. Inferred different dependency than source.
26
27
error.useCallback-aliased-var.ts:9:21
28
7 | const aliasedProp = x.y.z;
29
8 |
30
> 9 | return useCallback(() => [aliasedX, x.y.z], [x, aliasedProp]);
31
- | ^^^^^^^^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
31
+ | ^^^^^^^^^^^^^^^^^^^^^^^ Could not preserve existing manual memoization
32
10 | }
33
11 |
34
-
35
-
34
```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-conditional-access-noAlloc.expect.md
+3
-5
@@ -26,9 +26,9 @@ export const FIXTURE_ENTRYPOINT = {
26
27
```
28
Found 1 error:
29
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
29
+Memoization: Compilation skipped because existing memoization could not be preserved
30
31
-The inferred dependency was `propB?.x.y`, but the source dependencies were [propA, propB.x.y]. Inferred different dependency than source.
31
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB?.x.y`, but the source dependencies were [propA, propB.x.y]. Inferred different dependency than source.
32
33
error.useCallback-conditional-access-noAlloc.ts:5:21
34
3 |
@@ -44,12 +44,10 @@ error.useCallback-conditional-access-noAlloc.ts:5:21
44
> 9 | };
45
| ^^^^^^^^^^^^
46
> 10 | }, [propA, propB.x.y]);
47
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
47
+ | ^^^^ Could not preserve existing manual memoization
48
11 | }
49
12 |
50
13 | export const FIXTURE_ENTRYPOINT = {
51
-
52
-
51
```
52
53
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-infer-less-specific-conditional-access.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component({propA, propB}) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
31
32
error.useCallback-infer-less-specific-conditional-access.ts:6:21
33
4 |
@@ -49,11 +49,9 @@ error.useCallback-infer-less-specific-conditional-access.ts:6:21
49
> 13 | }
50
| ^^^^^^^^^^^^^^^^^
51
> 14 | }, [propA?.a, propB.x.y]);
52
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
52
+ | ^^^^ Could not preserve existing manual memoization
53
15 | }
54
16 |
55
-
56
-
55
```
56
57
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-property-call-dep.expect.md
+3
-5
@@ -18,9 +18,9 @@ function Component({propA}) {
18
19
```
20
Found 1 error:
21
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
21
+Memoization: Compilation skipped because existing memoization could not be preserved
22
23
-The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
23
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
24
25
error.useCallback-property-call-dep.ts:5:21
26
3 |
@@ -30,11 +30,9 @@ error.useCallback-property-call-dep.ts:5:21
30
> 6 | return propA.x();
31
| ^^^^^^^^^^^^^^^^^^^^^
32
> 7 | }, [propA.x]);
33
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
33
+ | ^^^^ Could not preserve existing manual memoization
34
8 | }
35
9 |
36
-
37
-
36
```
37
38
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-aliased-var.expect.md
+3
-5
@@ -20,19 +20,17 @@ function useHook(x) {
20
21
```
22
Found 1 error:
23
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
23
+Memoization: Compilation skipped because existing memoization could not be preserved
24
25
-The inferred dependency was `x`, but the source dependencies were [aliasedX, aliasedProp]. Inferred different dependency than source.
25
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `x`, but the source dependencies were [aliasedX, aliasedProp]. Inferred different dependency than source.
26
27
error.useMemo-aliased-var.ts:9:17
28
7 | const aliasedProp = x.y.z;
29
8 |
30
> 9 | return useMemo(() => [x, x.y.z], [aliasedX, aliasedProp]);
31
- | ^^^^^^^^^^^^^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
31
+ | ^^^^^^^^^^^^^^^^ Could not preserve existing manual memoization
32
10 | }
33
11 |
34
-
35
-
34
```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-infer-less-specific-conditional-access.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component({propA, propB}) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
31
32
error.useMemo-infer-less-specific-conditional-access.ts:6:17
33
4 |
@@ -49,11 +49,9 @@ error.useMemo-infer-less-specific-conditional-access.ts:6:17
49
> 13 | }
50
| ^^^^^^^^^^^^^^^^^
51
> 14 | }, [propA?.a, propB.x.y]);
52
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
52
+ | ^^^^ Could not preserve existing manual memoization
53
15 | }
54
16 |
55
-
56
-
55
```
56
57
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-infer-less-specific-conditional-value-block.expect.md
+6
-10
@@ -25,9 +25,9 @@ function Component({propA, propB}) {
25
26
```
27
Found 2 errors:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
31
32
error.useMemo-infer-less-specific-conditional-value-block.ts:6:17
33
4 |
@@ -49,14 +49,12 @@ error.useMemo-infer-less-specific-conditional-value-block.ts:6:17
49
> 13 | }
50
| ^^^^^^^^^^^^^^^^^
51
> 14 | }, [propA.a, propB.x.y]);
52
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
52
+ | ^^^^ Could not preserve existing manual memoization
53
15 | }
54
16 |
55
+Memoization: Compilation skipped because existing memoization could not be preserved
56
56
-
57
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
58
-
59
-The inferred dependency was `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
57
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
58
59
error.useMemo-infer-less-specific-conditional-value-block.ts:6:17
60
4 |
@@ -78,11 +76,9 @@ error.useMemo-infer-less-specific-conditional-value-block.ts:6:17
76
> 13 | }
77
| ^^^^^^^^^^^^^^^^^
78
> 14 | }, [propA.a, propB.x.y]);
81
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
79
+ | ^^^^ Could not preserve existing manual memoization
80
15 | }
81
16 |
84
-
85
-
82
```
83
84
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-property-call-chained-object.expect.md
+3
-5
@@ -20,9 +20,9 @@ function Component({propA}) {
20
21
```
22
Found 1 error:
23
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
23
+Memoization: Compilation skipped because existing memoization could not be preserved
24
25
-The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
25
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
26
27
error.useMemo-property-call-chained-object.ts:5:17
28
3 |
@@ -36,11 +36,9 @@ error.useMemo-property-call-chained-object.ts:5:17
36
> 8 | };
37
| ^^^^^^^^^^^^
38
> 9 | }, [propA.x]);
39
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
39
+ | ^^^^ Could not preserve existing manual memoization
40
10 | }
41
11 |
42
-
43
-
42
```
43
44
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-property-call-dep.expect.md
+3
-5
@@ -18,9 +18,9 @@ function Component({propA}) {
18
19
```
20
Found 1 error:
21
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
21
+Memoization: Compilation skipped because existing memoization could not be preserved
22
23
-The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
23
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
24
25
error.useMemo-property-call-dep.ts:5:17
26
3 |
@@ -30,11 +30,9 @@ error.useMemo-property-call-dep.ts:5:17
30
> 6 | return propA.x();
31
| ^^^^^^^^^^^^^^^^^^^^^
32
> 7 | }, [propA.x]);
33
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
33
+ | ^^^^ Could not preserve existing manual memoization
34
8 | }
35
9 |
36
-
37
-
36
```
37
38
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-unrelated-mutation-in-depslist.expect.md
+3
-5
@@ -31,9 +31,9 @@ function useFoo(input1) {
31
32
```
33
Found 1 error:
34
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
34
+Memoization: Compilation skipped because existing memoization could not be preserved
35
36
-The inferred dependency was `input1`, but the source dependencies were [y]. Inferred different dependency than source.
36
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `input1`, but the source dependencies were [y]. Inferred different dependency than source.
37
38
error.useMemo-unrelated-mutation-in-depslist.ts:16:27
39
14 | const x = {};
@@ -43,12 +43,10 @@ error.useMemo-unrelated-mutation-in-depslist.ts:16:27
43
> 17 | return [y];
44
| ^^^^^^^^^^^^^^^
45
> 18 | }, [(mutate(x), y)]);
46
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
46
+ | ^^^^ Could not preserve existing manual memoization
47
19 |
48
20 | return [x, memoized];
49
21 | }
50
-
51
-
50
```
51
52
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-member-expression-with-conditional-optional.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component(props) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
31
32
error.todo-optional-member-expression-with-conditional-optional.ts:4:23
33
2 | import {ValidateMemoization} from 'shared-runtime';
@@ -47,12 +47,10 @@ error.todo-optional-member-expression-with-conditional-optional.ts:4:23
47
> 10 | return x;
48
| ^^^^^^^^^^^^^^^^^
49
> 11 | }, [props?.items, props.cond]);
50
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
50
+ | ^^^^ Could not preserve existing manual memoization
51
12 | return (
52
13 | <ValidateMemoization inputs={[props?.items, props.cond]} output={data} />
53
14 | );
54
-
55
-
54
```
55
56
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-member-expression-with-conditional.expect.md
+3
-5
@@ -25,9 +25,9 @@ function Component(props) {
25
26
```
27
Found 1 error:
28
-Memoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
28
+Memoization: Compilation skipped because existing memoization could not be preserved
29
30
-The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
30
+React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
31
32
error.todo-optional-member-expression-with-conditional.ts:4:23
33
2 | import {ValidateMemoization} from 'shared-runtime';
@@ -47,12 +47,10 @@ error.todo-optional-member-expression-with-conditional.ts:4:23
47
> 10 | return x;
48
| ^^^^^^^^^^^^^^^^^
49
> 11 | }, [props?.items, props.cond]);
50
- | ^^^^ React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected
50
+ | ^^^^ Could not preserve existing manual memoization
51
12 | return (
52
13 | <ValidateMemoization inputs={[props?.items, props.cond]} output={data} />
53
14 | );
54
-
55
-
54
```
55
56
\ No newline at end of file