[compiler] Fix VariableDeclarator source location (#35348)
Putting up https://github.com/facebook/react/pull/35129 again Reverted in https://github.com/facebook/react/pull/35346 after breaking main before security patch This change impacts output formatting in a lot of snaps, so is very sensitive to additions in main to the fixtures resulting in broken tests after merging, so we should try merge quickly after rebasing or do a fast follow to the merge with a snap update.
Nathan committed
Dec 11, 2025 at 15:02 UTC
b85cf6af3de99dce3674dadebcc1493b77a64606
175 files changed
+459
-399
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts
+2
@@ -4026,6 +4026,7 @@ function lowerAssignment(
4026
pattern: {
4027
kind: 'ArrayPattern',
4028
items,
4029
+ loc: lvalue.node.loc ?? GeneratedSource,
4030
},
4031
},
4032
value,
@@ -4203,6 +4204,7 @@ function lowerAssignment(
4204
pattern: {
4205
kind: 'ObjectPattern',
4206
properties,
4207
+ loc: lvalue.node.loc ?? GeneratedSource,
4208
},
4209
},
4210
value,
compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
+2
@@ -694,11 +694,13 @@ export type SpreadPattern = {
694
export type ArrayPattern = {
695
kind: 'ArrayPattern';
696
items: Array<Place | SpreadPattern | Hole>;
697
+ loc: SourceLocation;
698
};
699
700
export type ObjectPattern = {
701
kind: 'ObjectPattern';
702
properties: Array<ObjectProperty | SpreadPattern>;
703
+ loc: SourceLocation;
704
};
705
706
export type ObjectPropertyKey =
compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineJsx.ts
+1
@@ -515,6 +515,7 @@ function emitDestructureProps(
515
pattern: {
516
kind: 'ObjectPattern',
517
properties,
518
+ loc: GeneratedSource,
519
},
520
kind: InstructionKind.Let,
521
},
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts
+38
-8
@@ -702,7 +702,7 @@ function codegenReactiveScope(
702
outputComments.push(name.name);
703
if (!cx.hasDeclared(identifier)) {
704
statements.push(
705
- t.variableDeclaration('let', [t.variableDeclarator(name)]),
705
+ t.variableDeclaration('let', [createVariableDeclarator(name, null)]),
706
);
707
}
708
cacheLoads.push({name, index, value: wrapCacheDep(cx, name)});
@@ -1387,7 +1387,7 @@ function codegenInstructionNullable(
1387
suggestions: null,
1388
});
1389
return createVariableDeclaration(instr.loc, 'const', [
1390
- t.variableDeclarator(codegenLValue(cx, lvalue), value),
1390
+ createVariableDeclarator(codegenLValue(cx, lvalue), value),
1391
]);
1392
}
1393
case InstructionKind.Function: {
@@ -1451,7 +1451,7 @@ function codegenInstructionNullable(
1451
suggestions: null,
1452
});
1453
return createVariableDeclaration(instr.loc, 'let', [
1454
- t.variableDeclarator(codegenLValue(cx, lvalue), value),
1454
+ createVariableDeclarator(codegenLValue(cx, lvalue), value),
1455
]);
1456
}
1457
case InstructionKind.Reassign: {
@@ -1691,6 +1691,9 @@ function withLoc<T extends (...args: Array<any>) => t.Node>(
1691
};
1692
}
1693
1694
+const createIdentifier = withLoc(t.identifier);
1695
+const createArrayPattern = withLoc(t.arrayPattern);
1696
+const createObjectPattern = withLoc(t.objectPattern);
1697
const createBinaryExpression = withLoc(t.binaryExpression);
1698
const createExpressionStatement = withLoc(t.expressionStatement);
1699
const _createLabelledStatement = withLoc(t.labeledStatement);
@@ -1722,6 +1725,31 @@ const createTryStatement = withLoc(t.tryStatement);
1725
const createBreakStatement = withLoc(t.breakStatement);
1726
const createContinueStatement = withLoc(t.continueStatement);
1727
1728
+function createVariableDeclarator(
1729
+ id: t.LVal,
1730
+ init?: t.Expression | null,
1731
+): t.VariableDeclarator {
1732
+ const node = t.variableDeclarator(id, init);
1733
+
1734
+ /*
1735
+ * The variable declarator location is not preserved in HIR, however, we can use the
1736
+ * start location of the id and the end location of the init to recreate the
1737
+ * exact original variable declarator location.
1738
+ *
1739
+ * Or if init is null, we likely have a declaration without an initializer, so we can use the id.loc.end as the end location.
1740
+ */
1741
+ if (id.loc && (init === null || init?.loc)) {
1742
+ node.loc = {
1743
+ start: id.loc.start,
1744
+ end: init?.loc?.end ?? id.loc.end,
1745
+ filename: id.loc.filename,
1746
+ identifierName: undefined,
1747
+ };
1748
+ }
1749
+
1750
+ return node;
1751
+}
1752
+
1753
function createHookGuard(
1754
guard: ExternalFunction,
1755
context: ProgramContext,
@@ -1829,7 +1857,7 @@ function codegenInstruction(
1857
);
1858
} else {
1859
return createVariableDeclaration(instr.loc, 'const', [
1832
- t.variableDeclarator(
1860
+ createVariableDeclarator(
1861
convertIdentifier(instr.lvalue.identifier),
1862
expressionValue,
1863
),
@@ -2756,7 +2784,7 @@ function codegenArrayPattern(
2784
): t.ArrayPattern {
2785
const hasHoles = !pattern.items.every(e => e.kind !== 'Hole');
2786
if (hasHoles) {
2759
- const result = t.arrayPattern([]);
2787
+ const result = createArrayPattern(pattern.loc, []);
2788
/*
2789
* Older versions of babel have a validation bug fixed by
2790
* https://github.com/babel/babel/pull/10917
@@ -2777,7 +2805,8 @@ function codegenArrayPattern(
2805
}
2806
return result;
2807
} else {
2780
- return t.arrayPattern(
2808
+ return createArrayPattern(
2809
+ pattern.loc,
2810
pattern.items.map(item => {
2811
if (item.kind === 'Hole') {
2812
return null;
@@ -2797,7 +2826,8 @@ function codegenLValue(
2826
return codegenArrayPattern(cx, pattern);
2827
}
2828
case 'ObjectPattern': {
2800
- return t.objectPattern(
2829
+ return createObjectPattern(
2830
+ pattern.loc,
2831
pattern.properties.map(property => {
2832
if (property.kind === 'ObjectProperty') {
2833
const key = codegenObjectPropertyKey(cx, property.key);
@@ -2916,7 +2946,7 @@ function convertIdentifier(identifier: Identifier): t.Identifier {
2946
suggestions: null,
2947
},
2948
);
2919
- return t.identifier(identifier.name.value);
2949
+ return createIdentifier(identifier.loc, identifier.name.value);
2950
}
2951
2952
function compareScopeDependency(
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts
+116
-26
@@ -27,7 +27,11 @@ import {Result} from '../Utils/Result';
27
28
/**
29
* Some common node types that are important for coverage tracking.
30
- * Based on istanbul-lib-instrument
30
+ * Based on istanbul-lib-instrument + some other common nodes we expect to be present in the generated AST.
31
+ *
32
+ * Note: For VariableDeclaration, VariableDeclarator, and Identifier, we enforce stricter validation
33
+ * that requires both the source location AND node type to match in the generated AST. This ensures
34
+ * that variable declarations maintain their structural integrity through compilation.
35
*/
36
const IMPORTANT_INSTRUMENTED_TYPES = new Set([
37
'ArrowFunctionExpression',
@@ -54,6 +58,14 @@ const IMPORTANT_INSTRUMENTED_TYPES = new Set([
58
'LabeledStatement',
59
'ConditionalExpression',
60
'LogicalExpression',
61
+
62
+ /**
63
+ * Note: these aren't important for coverage tracking,
64
+ * but we still want to track them to ensure we aren't regressing them when
65
+ * we fix the source location tracking for other nodes.
66
+ */
67
+ 'VariableDeclaration',
68
+ 'Identifier',
69
]);
70
71
/**
@@ -114,10 +126,13 @@ export function validateSourceLocations(
126
): Result<void, CompilerError> {
127
const errors = new CompilerError();
128
117
- // Step 1: Collect important locations from the original source
129
+ /*
130
+ * Step 1: Collect important locations from the original source
131
+ * Note: Multiple node types can share the same location (e.g. VariableDeclarator and Identifier)
132
+ */
133
const importantOriginalLocations = new Map<
134
string,
120
- {loc: t.SourceLocation; nodeType: string}
135
+ {loc: t.SourceLocation; nodeTypes: Set<string>}
136
>();
137
138
func.traverse({
@@ -137,20 +152,31 @@ export function validateSourceLocations(
152
// Collect the location if it exists
153
if (node.loc) {
154
const key = locationKey(node.loc);
140
- importantOriginalLocations.set(key, {
141
- loc: node.loc,
142
- nodeType: node.type,
143
- });
155
+ const existing = importantOriginalLocations.get(key);
156
+ if (existing) {
157
+ existing.nodeTypes.add(node.type);
158
+ } else {
159
+ importantOriginalLocations.set(key, {
160
+ loc: node.loc,
161
+ nodeTypes: new Set([node.type]),
162
+ });
163
+ }
164
}
165
},
166
});
167
148
- // Step 2: Collect all locations from the generated AST
149
- const generatedLocations = new Set<string>();
168
+ // Step 2: Collect all locations from the generated AST with their node types
169
+ const generatedLocations = new Map<string, Set<string>>();
170
171
function collectGeneratedLocations(node: t.Node): void {
172
if (node.loc) {
153
- generatedLocations.add(locationKey(node.loc));
173
+ const key = locationKey(node.loc);
174
+ const nodeTypes = generatedLocations.get(key);
175
+ if (nodeTypes) {
176
+ nodeTypes.add(node.type);
177
+ } else {
178
+ generatedLocations.set(key, new Set([node.type]));
179
+ }
180
}
181
182
// Use Babel's VISITOR_KEYS to traverse only actual node properties
@@ -183,22 +209,86 @@ export function validateSourceLocations(
209
collectGeneratedLocations(outlined.fn.body);
210
}
211
186
- // Step 3: Validate that all important locations are preserved
187
- for (const [key, {loc, nodeType}] of importantOriginalLocations) {
188
- if (!generatedLocations.has(key)) {
189
- errors.pushDiagnostic(
190
- CompilerDiagnostic.create({
191
- category: ErrorCategory.Todo,
192
- reason: 'Important source location missing in generated code',
193
- description:
194
- `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
195
- `to fail to track this code properly, resulting in inaccurate coverage reports.`,
196
- }).withDetails({
197
- kind: 'error',
198
- loc,
199
- message: null,
200
- }),
201
- );
212
+ /*
213
+ * Step 3: Validate that all important locations are preserved
214
+ * For certain node types, also validate that the node type matches
215
+ */
216
+ const strictNodeTypes = new Set([
217
+ 'VariableDeclaration',
218
+ 'VariableDeclarator',
219
+ 'Identifier',
220
+ ]);
221
+
222
+ const reportMissingLocation = (
223
+ loc: t.SourceLocation,
224
+ nodeType: string,
225
+ ): void => {
226
+ errors.pushDiagnostic(
227
+ CompilerDiagnostic.create({
228
+ category: ErrorCategory.Todo,
229
+ reason: 'Important source location missing in generated code',
230
+ description:
231
+ `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
232
+ `to fail to track this code properly, resulting in inaccurate coverage reports.`,
233
+ }).withDetails({
234
+ kind: 'error',
235
+ loc,
236
+ message: null,
237
+ }),
238
+ );
239
+ };
240
+
241
+ const reportWrongNodeType = (
242
+ loc: t.SourceLocation,
243
+ expectedType: string,
244
+ actualTypes: Set<string>,
245
+ ): void => {
246
+ errors.pushDiagnostic(
247
+ CompilerDiagnostic.create({
248
+ category: ErrorCategory.Todo,
249
+ reason:
250
+ 'Important source location has wrong node type in generated code',
251
+ description:
252
+ `Source location for ${expectedType} exists in the generated output but with wrong node type(s): ${Array.from(actualTypes).join(', ')}. ` +
253
+ `This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports.`,
254
+ }).withDetails({
255
+ kind: 'error',
256
+ loc,
257
+ message: null,
258
+ }),
259
+ );
260
+ };
261
+
262
+ for (const [key, {loc, nodeTypes}] of importantOriginalLocations) {
263
+ const generatedNodeTypes = generatedLocations.get(key);
264
+
265
+ if (!generatedNodeTypes) {
266
+ // Location is completely missing
267
+ reportMissingLocation(loc, Array.from(nodeTypes).join(', '));
268
+ } else {
269
+ // Location exists, check each node type
270
+ for (const nodeType of nodeTypes) {
271
+ if (
272
+ strictNodeTypes.has(nodeType) &&
273
+ !generatedNodeTypes.has(nodeType)
274
+ ) {
275
+ /*
276
+ * For strict node types, the specific node type must be present
277
+ * Check if any generated node type is also an important original node type
278
+ */
279
+ const hasValidNodeType = Array.from(generatedNodeTypes).some(
280
+ genType => nodeTypes.has(genType),
281
+ );
282
+
283
+ if (hasValidNodeType) {
284
+ // At least one generated node type is valid (also in original), so this is just missing
285
+ reportMissingLocation(loc, nodeType);
286
+ } else {
287
+ // None of the generated node types are in original - this is wrong node type
288
+ reportWrongNodeType(loc, nodeType, generatedNodeTypes);
289
+ }
290
+ }
291
+ }
292
}
293
}
294
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/alias-capture-in-method-receiver-and-mutate.expect.md
-2
@@ -35,10 +35,8 @@ function Component() {
35
let t0;
36
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37
const a = makeObject_Primitives();
38
-
38
const x = [];
39
x.push(a);
41
-
40
mutate(x);
41
t0 = [x, a];
42
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/alias-capture-in-method-receiver.expect.md
-1
@@ -33,7 +33,6 @@ function Component() {
33
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
34
const x = [];
35
x.push(a);
36
-
36
t1 = [x, a];
37
$[1] = t1;
38
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-fn-expr.expect.md
-4
@@ -85,14 +85,10 @@ function Component(t0) {
85
let t1;
86
if ($[0] !== prop) {
87
const obj = shallowCopy(prop);
88
-
88
const aliasedObj = identity(obj);
90
-
89
const getId = () => obj.id;
92
-
90
mutate(aliasedObj);
91
setPropertyByKey(aliasedObj, "id", prop.id + 1);
95
-
92
t1 = <Stringify getId={getId} shouldInvokeFns={true} />;
93
$[0] = prop;
94
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-truncated-dep.expect.md
-3
@@ -181,12 +181,9 @@ function Component(t0) {
181
if ($[0] !== prop) {
182
const obj = shallowCopy(prop);
183
const aliasedObj = identity(obj);
184
-
184
const id = [obj.id];
186
-
185
mutate(aliasedObj);
186
setPropertyByKey(aliasedObj, "id", prop.id + 1);
189
-
187
t1 = <Stringify id={id} />;
188
$[0] = prop;
189
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/align-scopes-within-nested-valueblock-in-array.expect.md
-1
@@ -54,7 +54,6 @@ function Foo(t0) {
54
let t1;
55
if ($[0] !== cond1 || $[1] !== cond2) {
56
const arr = makeArray({ a: 2 }, 2, []);
57
-
57
t1 = cond1 ? (
58
<>
59
<div>{identity("foo")}</div>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-mutating-ref-in-callback-passed-to-jsx-indirect.expect.md
-1
@@ -49,7 +49,6 @@ function Component() {
49
ref.current = "";
50
}
51
};
52
-
52
t0 = () => {
53
setRef();
54
};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-mutating-ref-property-in-callback-passed-to-jsx-indirect.expect.md
-1
@@ -49,7 +49,6 @@ function Component() {
49
ref.current.value = "";
50
}
51
};
52
-
52
t0 = () => {
53
setRef();
54
};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-event-handler-wrapper.expect.md
-1
@@ -74,7 +74,6 @@ function Component() {
74
console.log(ref.current.value);
75
}
76
};
77
-
77
t0 = (
78
<>
79
<input ref={ref} />
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-type-cast-in-render.expect.md
-1
@@ -36,7 +36,6 @@ function useArrayOfRef() {
36
const callback = (value) => {
37
ref.current = value;
38
};
39
-
39
t0 = [callback];
40
$[0] = t0;
41
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-at-closure.expect.md
-1
@@ -35,7 +35,6 @@ function Component(props) {
35
const arr = [...bar(props)];
36
return arr.at(x);
37
};
38
-
38
t1 = fn();
39
$[2] = props;
40
$[3] = x;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-spread-mutable-iterator.expect.md
-1
@@ -61,7 +61,6 @@ function useBar(t0) {
61
if ($[0] !== arg) {
62
const s = new Set([1, 5, 4]);
63
const mutableIterator = s.values();
64
-
64
t1 = [arg, ...mutableIterator];
65
$[0] = arg;
66
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call.expect.md
-1
@@ -28,7 +28,6 @@ function Component(props) {
28
const a = [];
29
const b = {};
30
foo(a, b);
31
-
31
foo(b);
32
t0 = <div a={a} b={b} />;
33
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capture-ref-for-later-mutation.expect.md
-1
@@ -45,7 +45,6 @@ function useKeyCommand() {
45
const nextPosition = direction === "left" ? addOne(position) : position;
46
currentPosition.current = nextPosition;
47
};
48
-
48
const moveLeft = { handler: handleKey("left") };
49
const moveRight = { handler: handleKey("right") };
50
t0 = [moveLeft, moveRight];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md
-1
@@ -45,7 +45,6 @@ function Component(t0) {
45
z.a = 2;
46
mutate(y.b);
47
};
48
-
48
x();
49
t1 = [y, z];
50
$[0] = a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-emit-make-read-only.expect.md
-1
@@ -29,7 +29,6 @@ function MyComponentName(props) {
29
const x = {};
30
foo(x, props.a);
31
foo(x, props.b);
32
-
32
y = [];
33
y.push(x);
34
$[0] = props.a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-inline-iife-reassign.expect.md
-1
@@ -34,7 +34,6 @@ function useTest() {
34
let t0;
35
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36
let w = {};
37
-
37
const t1 = (w = 42);
38
const t2 = w;
39
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-inline-iife-storeprop.expect.md
-1
@@ -34,7 +34,6 @@ function useTest() {
34
let t0;
35
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36
const w = {};
37
-
37
const t1 = (w.x = 42);
38
const t2 = w.x;
39
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md
-4
@@ -44,11 +44,9 @@ function ComponentA(props) {
44
if (b) {
45
a.push(props.p0);
46
}
47
-
47
if (props.p1) {
48
b.push(props.p2);
49
}
51
-
50
t0 = <Foo a={a} b={b} />;
51
$[0] = props.p0;
52
$[1] = props.p1;
@@ -69,11 +67,9 @@ function ComponentB(props) {
67
if (mayMutate(b)) {
68
a.push(props.p0);
69
}
72
-
70
if (props.p1) {
71
b.push(props.p2);
72
}
76
-
73
t0 = <Foo a={a} b={b} />;
74
$[0] = props.p0;
75
$[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constructor.expect.md
-1
@@ -28,7 +28,6 @@ function Component(props) {
28
const a = [];
29
const b = {};
30
new Foo(a, b);
31
-
31
new Foo(b);
32
t0 = <div a={a} b={b} />;
33
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/context-variable-reassigned-outside-of-lambda.expect.md
-1
@@ -34,7 +34,6 @@ function Component(props) {
34
const callback = () => {
35
console.log(x);
36
};
37
-
37
x = {};
38
t0 = <Stringify callback={callback} shouldInvokeFns={true} />;
39
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md
-3
@@ -75,7 +75,6 @@ function Component(props) {
75
let t0;
76
if ($[0] !== post) {
77
const allUrls = [];
78
-
78
const { media: t1, comments: t2, urls: t3 } = post;
79
const media = t1 === undefined ? null : t1;
80
let t4;
@@ -102,7 +101,6 @@ function Component(props) {
101
if (!comments.length) {
102
return;
103
}
105
-
104
console.log(comments.length);
105
};
106
$[6] = comments.length;
@@ -111,7 +109,6 @@ function Component(props) {
109
t6 = $[7];
110
}
111
const onClick = t6;
114
-
112
allUrls.push(...urls);
113
t0 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
114
$[0] = post;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md
-3
@@ -53,7 +53,6 @@ function Component(props) {
53
let t0;
54
if ($[0] !== post) {
55
const allUrls = [];
56
-
56
const { media, comments, urls } = post;
57
let t1;
58
if ($[2] !== comments.length) {
@@ -61,7 +60,6 @@ function Component(props) {
60
if (!comments.length) {
61
return;
62
}
64
-
63
console.log(comments.length);
64
};
65
$[2] = comments.length;
@@ -70,7 +68,6 @@ function Component(props) {
68
t1 = $[3];
69
}
70
const onClick = t1;
73
-
71
allUrls.push(...urls);
72
t0 = <Media media={media} onClick={onClick} />;
73
$[0] = post;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md
-1
@@ -57,7 +57,6 @@ function Component(t0) {
57
let y;
58
if ($[0] !== a || $[1] !== b || $[2] !== c) {
59
x = [];
60
-
60
if (a) {
61
let t1;
62
if ($[5] !== b) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/derived-state-conditionally-in-effect.expect.md
-1
@@ -46,7 +46,6 @@ function Component(t0) {
46
setLocalValue("disabled");
47
}
48
};
49
-
49
t2 = [value, enabled];
50
$[0] = enabled;
51
$[1] = value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/function-expression-mutation-edge-case.expect.md
-3
@@ -65,17 +65,14 @@ function Component() {
65
if ($[2] !== bar || $[3] !== foo) {
66
t2 = () => {
67
let isChanged = false;
68
-
68
const newData = foo.map((val) => {
69
bar.someMethod(val);
70
isChanged = true;
71
});
73
-
72
if (isChanged) {
73
setFoo(newData);
74
}
75
};
78
-
76
t3 = [foo, bar];
77
$[2] = bar;
78
$[3] = foo;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/ref-conditional-in-effect-no-error.expect.md
-1
@@ -50,7 +50,6 @@ export default function Component(t0) {
50
setLocal(test + test);
51
}
52
};
53
-
53
t2 = [test];
54
$[0] = test;
55
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.expect.md
+282
-112
@@ -10,14 +10,28 @@ function Component({prop1, prop2}) {
10
const y = x * 2;
11
const arr = [x, y];
12
const obj = {x, y};
13
+ let destA, destB;
14
+ if (y > 5) {
15
+ [destA, destB] = arr;
16
+ }
17
+
18
const [a, b] = arr;
19
const {x: c, y: d} = obj;
20
+ let sound;
21
+
22
+ if (y > 10) {
23
+ sound = 'woof';
24
+ } else {
25
+ sound = 'meow';
26
+ }
27
28
useEffect(() => {
29
if (a > 10) {
30
console.log(a);
31
+ console.log(sound);
32
+ console.log(destA, destB);
33
}
20
- }, [a]);
34
+ }, [a, sound, destA, destB]);
35
36
const foo = useCallback(() => {
37
return a + b;
@@ -38,187 +52,343 @@ function Component({prop1, prop2}) {
52
## Error
53
54
```
41
-Found 13 errors:
55
+Found 25 errors:
56
57
Todo: Important source location missing in generated code
58
45
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
59
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
60
47
-error.todo-missing-source-locations.ts:5:8
61
+error.todo-missing-source-locations.ts:4:9
62
+ 2 | import {useEffect, useCallback} from 'react';
63
3 |
49
- 4 | function Component({prop1, prop2}) {
50
-> 5 | const x = prop1 + prop2;
51
- | ^^^^^^^^^^^^^^^^^
64
+> 4 | function Component({prop1, prop2}) {
65
+ | ^^^^^^^^^
66
+ 5 | const x = prop1 + prop2;
67
6 | const y = x * 2;
68
7 | const arr = [x, y];
54
- 8 | const obj = {x, y};
69
70
Todo: Important source location missing in generated code
71
58
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
72
+Source location for VariableDeclaration is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
73
60
-error.todo-missing-source-locations.ts:6:8
61
- 4 | function Component({prop1, prop2}) {
62
- 5 | const x = prop1 + prop2;
63
-> 6 | const y = x * 2;
64
- | ^^^^^^^^^
65
- 7 | const arr = [x, y];
66
- 8 | const obj = {x, y};
67
- 9 | const [a, b] = arr;
74
+error.todo-missing-source-locations.ts:9:2
75
+ 7 | const arr = [x, y];
76
+ 8 | const obj = {x, y};
77
+> 9 | let destA, destB;
78
+ | ^^^^^^^^^^^^^^^^^
79
+ 10 | if (y > 5) {
80
+ 11 | [destA, destB] = arr;
81
+ 12 | }
82
83
Todo: Important source location missing in generated code
84
71
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
85
+Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
86
73
-error.todo-missing-source-locations.ts:7:8
74
- 5 | const x = prop1 + prop2;
75
- 6 | const y = x * 2;
76
-> 7 | const arr = [x, y];
77
- | ^^^^^^^^^^^^
78
- 8 | const obj = {x, y};
79
- 9 | const [a, b] = arr;
80
- 10 | const {x: c, y: d} = obj;
87
+error.todo-missing-source-locations.ts:11:4
88
+ 9 | let destA, destB;
89
+ 10 | if (y > 5) {
90
+> 11 | [destA, destB] = arr;
91
+ | ^^^^^^^^^^^^^^^^^^^^^
92
+ 12 | }
93
+ 13 |
94
+ 14 | const [a, b] = arr;
95
96
Todo: Important source location missing in generated code
97
84
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
98
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
99
86
-error.todo-missing-source-locations.ts:8:8
87
- 6 | const y = x * 2;
88
- 7 | const arr = [x, y];
89
-> 8 | const obj = {x, y};
90
- | ^^^^^^^^^^^^
91
- 9 | const [a, b] = arr;
92
- 10 | const {x: c, y: d} = obj;
93
- 11 |
100
+error.todo-missing-source-locations.ts:15:9
101
+ 13 |
102
+ 14 | const [a, b] = arr;
103
+> 15 | const {x: c, y: d} = obj;
104
+ | ^
105
+ 16 | let sound;
106
+ 17 |
107
+ 18 | if (y > 10) {
108
109
Todo: Important source location missing in generated code
110
97
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
111
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
112
99
-error.todo-missing-source-locations.ts:9:8
100
- 7 | const arr = [x, y];
101
- 8 | const obj = {x, y};
102
-> 9 | const [a, b] = arr;
103
- | ^^^^^^^^^^^^
104
- 10 | const {x: c, y: d} = obj;
105
- 11 |
106
- 12 | useEffect(() => {
113
+error.todo-missing-source-locations.ts:15:15
114
+ 13 |
115
+ 14 | const [a, b] = arr;
116
+> 15 | const {x: c, y: d} = obj;
117
+ | ^
118
+ 16 | let sound;
119
+ 17 |
120
+ 18 | if (y > 10) {
121
122
Todo: Important source location missing in generated code
123
110
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
124
+Source location for VariableDeclaration is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
125
112
-error.todo-missing-source-locations.ts:10:8
113
- 8 | const obj = {x, y};
114
- 9 | const [a, b] = arr;
115
-> 10 | const {x: c, y: d} = obj;
116
- | ^^^^^^^^^^^^^^^^^^
117
- 11 |
118
- 12 | useEffect(() => {
119
- 13 | if (a > 10) {
126
+error.todo-missing-source-locations.ts:16:2
127
+ 14 | const [a, b] = arr;
128
+ 15 | const {x: c, y: d} = obj;
129
+> 16 | let sound;
130
+ | ^^^^^^^^^^
131
+ 17 |
132
+ 18 | if (y > 10) {
133
+ 19 | sound = 'woof';
134
135
Todo: Important source location missing in generated code
136
137
Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
138
125
-error.todo-missing-source-locations.ts:12:2
126
- 10 | const {x: c, y: d} = obj;
127
- 11 |
128
-> 12 | useEffect(() => {
139
+error.todo-missing-source-locations.ts:19:4
140
+ 17 |
141
+ 18 | if (y > 10) {
142
+> 19 | sound = 'woof';
143
+ | ^^^^^^^^^^^^^^^
144
+ 20 | } else {
145
+ 21 | sound = 'meow';
146
+ 22 | }
147
+
148
+Todo: Important source location has wrong node type in generated code
149
+
150
+Source location for Identifier exists in the generated output but with wrong node type(s): ExpressionStatement. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
151
+
152
+error.todo-missing-source-locations.ts:19:4
153
+ 17 |
154
+ 18 | if (y > 10) {
155
+> 19 | sound = 'woof';
156
+ | ^^^^^
157
+ 20 | } else {
158
+ 21 | sound = 'meow';
159
+ 22 | }
160
+
161
+Todo: Important source location missing in generated code
162
+
163
+Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
164
+
165
+error.todo-missing-source-locations.ts:21:4
166
+ 19 | sound = 'woof';
167
+ 20 | } else {
168
+> 21 | sound = 'meow';
169
+ | ^^^^^^^^^^^^^^^
170
+ 22 | }
171
+ 23 |
172
+ 24 | useEffect(() => {
173
+
174
+Todo: Important source location has wrong node type in generated code
175
+
176
+Source location for Identifier exists in the generated output but with wrong node type(s): ExpressionStatement. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
177
+
178
+error.todo-missing-source-locations.ts:21:4
179
+ 19 | sound = 'woof';
180
+ 20 | } else {
181
+> 21 | sound = 'meow';
182
+ | ^^^^^
183
+ 22 | }
184
+ 23 |
185
+ 24 | useEffect(() => {
186
+
187
+Todo: Important source location missing in generated code
188
+
189
+Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
190
+
191
+error.todo-missing-source-locations.ts:24:2
192
+ 22 | }
193
+ 23 |
194
+> 24 | useEffect(() => {
195
| ^^^^^^^^^^^^^^^^^
130
-> 13 | if (a > 10) {
196
+> 25 | if (a > 10) {
197
| ^^^^^^^^^^^^^^^^^
132
-> 14 | console.log(a);
198
+> 26 | console.log(a);
199
| ^^^^^^^^^^^^^^^^^
134
-> 15 | }
200
+> 27 | console.log(sound);
201
| ^^^^^^^^^^^^^^^^^
136
-> 16 | }, [a]);
137
- | ^^^^^^^^^^^
138
- 17 |
139
- 18 | const foo = useCallback(() => {
140
- 19 | return a + b;
202
+> 28 | console.log(destA, destB);
203
+ | ^^^^^^^^^^^^^^^^^
204
+> 29 | }
205
+ | ^^^^^^^^^^^^^^^^^
206
+> 30 | }, [a, sound, destA, destB]);
207
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208
+ 31 |
209
+ 32 | const foo = useCallback(() => {
210
+ 33 | return a + b;
211
212
Todo: Important source location missing in generated code
213
214
Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
215
146
-error.todo-missing-source-locations.ts:14:6
147
- 12 | useEffect(() => {
148
- 13 | if (a > 10) {
149
-> 14 | console.log(a);
216
+error.todo-missing-source-locations.ts:26:6
217
+ 24 | useEffect(() => {
218
+ 25 | if (a > 10) {
219
+> 26 | console.log(a);
220
| ^^^^^^^^^^^^^^^
151
- 15 | }
152
- 16 | }, [a]);
153
- 17 |
221
+ 27 | console.log(sound);
222
+ 28 | console.log(destA, destB);
223
+ 29 | }
224
225
Todo: Important source location missing in generated code
226
157
-Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
227
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
228
159
-error.todo-missing-source-locations.ts:18:8
160
- 16 | }, [a]);
161
- 17 |
162
-> 18 | const foo = useCallback(() => {
163
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
164
-> 19 | return a + b;
165
- | ^^^^^^^^^^^^^^^^^
166
-> 20 | }, [a, b]);
167
- | ^^^^^^^^^^^^^
168
- 21 |
169
- 22 | function bar() {
170
- 23 | return (c + d) * 2;
229
+error.todo-missing-source-locations.ts:26:14
230
+ 24 | useEffect(() => {
231
+ 25 | if (a > 10) {
232
+> 26 | console.log(a);
233
+ | ^^^
234
+ 27 | console.log(sound);
235
+ 28 | console.log(destA, destB);
236
+ 29 | }
237
+
238
+Todo: Important source location missing in generated code
239
+
240
+Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
241
+
242
+error.todo-missing-source-locations.ts:27:6
243
+ 25 | if (a > 10) {
244
+ 26 | console.log(a);
245
+> 27 | console.log(sound);
246
+ | ^^^^^^^^^^^^^^^^^^^
247
+ 28 | console.log(destA, destB);
248
+ 29 | }
249
+ 30 | }, [a, sound, destA, destB]);
250
+
251
+Todo: Important source location missing in generated code
252
+
253
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
254
+
255
+error.todo-missing-source-locations.ts:27:14
256
+ 25 | if (a > 10) {
257
+ 26 | console.log(a);
258
+> 27 | console.log(sound);
259
+ | ^^^
260
+ 28 | console.log(destA, destB);
261
+ 29 | }
262
+ 30 | }, [a, sound, destA, destB]);
263
+
264
+Todo: Important source location missing in generated code
265
+
266
+Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
267
+
268
+error.todo-missing-source-locations.ts:28:6
269
+ 26 | console.log(a);
270
+ 27 | console.log(sound);
271
+> 28 | console.log(destA, destB);
272
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
273
+ 29 | }
274
+ 30 | }, [a, sound, destA, destB]);
275
+ 31 |
276
+
277
+Todo: Important source location missing in generated code
278
+
279
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
280
+
281
+error.todo-missing-source-locations.ts:28:14
282
+ 26 | console.log(a);
283
+ 27 | console.log(sound);
284
+> 28 | console.log(destA, destB);
285
+ | ^^^
286
+ 29 | }
287
+ 30 | }, [a, sound, destA, destB]);
288
+ 31 |
289
+
290
+Todo: Important source location missing in generated code
291
+
292
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
293
+
294
+error.todo-missing-source-locations.ts:32:14
295
+ 30 | }, [a, sound, destA, destB]);
296
+ 31 |
297
+> 32 | const foo = useCallback(() => {
298
+ | ^^^^^^^^^^^
299
+ 33 | return a + b;
300
+ 34 | }, [a, b]);
301
+ 35 |
302
303
Todo: Important source location missing in generated code
304
305
Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
306
176
-error.todo-missing-source-locations.ts:19:4
177
- 17 |
178
- 18 | const foo = useCallback(() => {
179
-> 19 | return a + b;
307
+error.todo-missing-source-locations.ts:33:4
308
+ 31 |
309
+ 32 | const foo = useCallback(() => {
310
+> 33 | return a + b;
311
| ^^^^^^^^^^^^^
181
- 20 | }, [a, b]);
182
- 21 |
183
- 22 | function bar() {
312
+ 34 | }, [a, b]);
313
+ 35 |
314
+ 36 | function bar() {
315
+
316
+Todo: Important source location missing in generated code
317
+
318
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
319
+
320
+error.todo-missing-source-locations.ts:34:6
321
+ 32 | const foo = useCallback(() => {
322
+ 33 | return a + b;
323
+> 34 | }, [a, b]);
324
+ | ^
325
+ 35 |
326
+ 36 | function bar() {
327
+ 37 | return (c + d) * 2;
328
+
329
+Todo: Important source location missing in generated code
330
+
331
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
332
+
333
+error.todo-missing-source-locations.ts:34:9
334
+ 32 | const foo = useCallback(() => {
335
+ 33 | return a + b;
336
+> 34 | }, [a, b]);
337
+ | ^
338
+ 35 |
339
+ 36 | function bar() {
340
+ 37 | return (c + d) * 2;
341
342
Todo: Important source location missing in generated code
343
344
Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
345
189
-error.todo-missing-source-locations.ts:23:4
190
- 21 |
191
- 22 | function bar() {
192
-> 23 | return (c + d) * 2;
346
+error.todo-missing-source-locations.ts:37:4
347
+ 35 |
348
+ 36 | function bar() {
349
+> 37 | return (c + d) * 2;
350
| ^^^^^^^^^^^^^^^^^^^
194
- 24 | }
195
- 25 |
196
- 26 | console.log('Hello, world!');
351
+ 38 | }
352
+ 39 |
353
+ 40 | console.log('Hello, world!');
354
355
Todo: Important source location missing in generated code
356
357
Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
358
202
-error.todo-missing-source-locations.ts:26:2
203
- 24 | }
204
- 25 |
205
-> 26 | console.log('Hello, world!');
359
+error.todo-missing-source-locations.ts:40:2
360
+ 38 | }
361
+ 39 |
362
+> 40 | console.log('Hello, world!');
363
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207
- 27 |
208
- 28 | return [y, foo, bar];
209
- 29 | }
364
+ 41 |
365
+ 42 | return [y, foo, bar];
366
+ 43 | }
367
+
368
+Todo: Important source location missing in generated code
369
+
370
+Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
371
+
372
+error.todo-missing-source-locations.ts:40:10
373
+ 38 | }
374
+ 39 |
375
+> 40 | console.log('Hello, world!');
376
+ | ^^^
377
+ 41 |
378
+ 42 | return [y, foo, bar];
379
+ 43 | }
380
381
Todo: Important source location missing in generated code
382
383
Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
384
215
-error.todo-missing-source-locations.ts:28:2
216
- 26 | console.log('Hello, world!');
217
- 27 |
218
-> 28 | return [y, foo, bar];
385
+error.todo-missing-source-locations.ts:42:2
386
+ 40 | console.log('Hello, world!');
387
+ 41 |
388
+> 42 | return [y, foo, bar];
389
| ^^^^^^^^^^^^^^^^^^^^^
220
- 29 | }
221
- 30 |
390
+ 43 | }
391
+ 44 |
392
```
393
394
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.js
+15
-1
@@ -6,14 +6,28 @@ function Component({prop1, prop2}) {
6
const y = x * 2;
7
const arr = [x, y];
8
const obj = {x, y};
9
+ let destA, destB;
10
+ if (y > 5) {
11
+ [destA, destB] = arr;
12
+ }
13
+
14
const [a, b] = arr;
15
const {x: c, y: d} = obj;
16
+ let sound;
17
+
18
+ if (y > 10) {
19
+ sound = 'woof';
20
+ } else {
21
+ sound = 'meow';
22
+ }
23
24
useEffect(() => {
25
if (a > 10) {
26
console.log(a);
27
+ console.log(sound);
28
+ console.log(destA, destB);
29
}
16
- }, [a]);
30
+ }, [a, sound, destA, destB]);
31
32
const foo = useCallback(() => {
33
return a + b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md
-1
@@ -44,7 +44,6 @@ function Component(props) {
44
let t0;
45
if ($[0] !== props.a) {
46
const a = [props.a];
47
-
47
t0 = [a];
48
$[0] = props.a;
49
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-newline.expect.md
-2
@@ -40,13 +40,11 @@ function Component(props) {
40
[
41
fbt._param(
42
"a really long description that got split into multiple lines",
43
-
43
props.name,
44
),
45
],
46
{ hk: "1euPUp" },
47
);
49
-
48
t0 = element.toString();
49
$[0] = props.name;
50
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-quotes.expect.md
+1
-8
@@ -32,16 +32,9 @@ function Component(props) {
32
if ($[0] !== props.name) {
33
const element = fbt._(
34
'Hello {"user" name}',
35
- [
36
- fbt._param(
37
- '"user" name',
38
-
39
- props.name,
40
- ),
41
- ],
35
+ [fbt._param('"user" name', props.name)],
36
{ hk: "S0vMe" },
37
);
44
-
38
t0 = element.toString();
39
$[0] = props.name;
40
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-unicode.expect.md
+1
-8
@@ -32,16 +32,9 @@ function Component(props) {
32
if ($[0] !== props.name) {
33
const element = fbt._(
34
"Hello {user name ☺}",
35
- [
36
- fbt._param(
37
- "user name \u263A",
38
-
39
- props.name,
40
- ),
41
- ],
35
+ [fbt._param("user name \u263A", props.name)],
36
{ hk: "1En1lp" },
37
);
44
-
38
t0 = element.toString();
39
$[0] = props.name;
40
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-to-string.expect.md
+1
-8
@@ -32,16 +32,9 @@ function Component(props) {
32
if ($[0] !== props.name) {
33
const element = fbt._(
34
"Hello {user name}",
35
- [
36
- fbt._param(
37
- "user name",
38
-
39
- props.name,
40
- ),
41
- ],
35
+ [fbt._param("user name", props.name)],
36
{ hk: "2zEDKF" },
37
);
44
-
38
t0 = element.toString();
39
$[0] = props.name;
40
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md
-1
@@ -78,7 +78,6 @@ function Component(t0) {
78
setState(5);
79
}
80
};
81
-
81
t3 = [state];
82
$[1] = state;
83
$[2] = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-in-statement.expect.md
-1
@@ -33,7 +33,6 @@ function Component(props) {
33
for (const key in props) {
34
items.push(<div key={key}>{key}</div>);
35
}
36
-
36
t0 = <div>{items}</div>;
37
$[0] = props;
38
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-loop-with-value-block-initializer.expect.md
-1
@@ -73,7 +73,6 @@ function Component(props) {
73
const item = props.items[i];
74
items.push(<div key={item.id}>{item.value}</div>);
75
}
76
-
76
t0 = <div>{items}</div>;
77
$[0] = props.items;
78
$[1] = props.start;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-mutate.expect.md
-1
@@ -38,7 +38,6 @@ function Component(_props) {
38
<div key={toJSON(item)}>{toJSON(mutateAndReturn(item))}</div>,
39
);
40
}
41
-
41
t0 = <div>{results}</div>;
42
$[0] = t0;
43
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/function-expression-maybe-mutates-hook-return-value.expect.md
-1
@@ -29,7 +29,6 @@ function Component(props) {
29
const onLoad = () => {
30
log(id);
31
};
32
-
32
t0 = <Foo onLoad={onLoad} />;
33
$[0] = id;
34
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/function-expression-prototype-call.expect.md
-1
@@ -27,7 +27,6 @@ function Component(props) {
27
const f = function () {
28
return <div>{props.name}</div>;
29
};
30
-
30
t0 = f.call();
31
$[0] = props;
32
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-jsx-tag-lowered-between-mutations.expect.md
-1
@@ -29,7 +29,6 @@ function Component(props) {
29
let t0;
30
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31
const maybeMutable = new MaybeMutable();
32
-
32
t0 = <View>{maybeMutate(maybeMutable)}</View>;
33
$[0] = t0;
34
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-types/set-constructor-arg.expect.md
-1
@@ -60,7 +60,6 @@ function useFoo(t0) {
60
if ($[3] !== propArr[1] || $[4] !== propArr[2]) {
61
s2 = new Set(MODULE_LOCAL.values());
62
s2.add(propArr[1]);
63
-
63
s3 = new Set(s2.values());
64
s3.add(propArr[2]);
65
$[3] = propArr[1];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-types/set-copy-constructor-mutate.expect.md
-1
@@ -41,7 +41,6 @@ function useFoo(t0) {
41
if ($[0] !== propArr[0]) {
42
s1 = new Set([1, 2, 3]);
43
s1.add(makeArray(propArr[0]));
44
-
44
s2 = new Set(s1);
45
46
mutate(s2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoist-destruct.expect.md
-1
@@ -37,7 +37,6 @@ function Foo() {
37
</div>
38
);
39
};
40
-
40
const [t1, t2] = [1, { x: 2 }];
41
const a = t1;
42
const { x: t3, y: t4 } = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-computed-member-expression.expect.md
-3
@@ -39,14 +39,11 @@ function hoisting() {
39
const onClick = function onClick() {
40
return bar.baz;
41
};
42
-
42
const onClick2 = function onClick2() {
43
return bar[baz];
44
};
46
-
45
const baz = "baz";
46
const bar = { baz: 1 };
49
-
47
t0 = (
48
<Stringify onClick={onClick} onClick2={onClick2} shouldInvokeFns={true} />
49
);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.expect.md
-1
@@ -66,7 +66,6 @@ function Component(t0) {
66
return null;
67
}
68
};
69
-
69
t1 = <Stringify shouldInvokeFns={true} callback={callback} />;
70
$[0] = isObjNull;
71
$[1] = obj;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-let-declaration-without-initialization.expect.md
-2
@@ -36,12 +36,10 @@ function useHook(t0) {
36
let t1;
37
if ($[0] !== cond) {
38
const getX = () => x;
39
-
39
let x;
40
if (cond) {
41
x = CONST_NUMBER1;
42
}
44
-
43
t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
44
$[0] = cond;
45
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-member-expression.expect.md
-2
@@ -34,9 +34,7 @@ function hoisting() {
34
const onClick = function onClick(x) {
35
return x + bar.baz;
36
};
37
-
37
const bar = { baz: 1 };
39
-
38
t0 = <Stringify onClick={onClick} />;
39
$[0] = t0;
40
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-nested-const-declaration.expect.md
-3
@@ -36,13 +36,10 @@ function hoisting() {
36
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37
const qux = () => {
38
let result;
39
-
39
result = foo();
40
return result;
41
};
43
-
42
const foo = () => bar + baz;
45
-
43
const bar = 3;
44
const baz = 2;
45
t0 = qux();
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-nested-let-declaration.expect.md
-3
@@ -36,13 +36,10 @@ function hoisting() {
36
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37
const qux = () => {
38
let result;
39
-
39
result = foo();
40
return result;
41
};
43
-
42
let foo = () => bar + baz;
45
-
43
let bar = 3;
44
const baz = 2;
45
t0 = qux();
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-object-method.expect.md
-1
@@ -36,7 +36,6 @@ function hoisting() {
36
},
37
};
38
const bar = _temp;
39
-
39
t0 = x.foo();
40
$[0] = t0;
41
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-reassigned-let-declaration.expect.md
-2
@@ -36,13 +36,11 @@ function useHook(t0) {
36
let t1;
37
if ($[0] !== cond) {
38
const getX = () => x;
39
-
39
let x = CONST_NUMBER0;
40
if (cond) {
41
x = x + CONST_NUMBER1;
42
x;
43
}
45
-
44
t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
45
$[0] = cond;
46
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-reassigned-twice-let-declaration.expect.md
-2
@@ -37,14 +37,12 @@ function useHook(t0) {
37
let t1;
38
if ($[0] !== cond) {
39
const getX = () => x;
40
-
40
let x = CONST_NUMBER0;
41
if (cond) {
42
x = x + CONST_NUMBER1;
43
x;
44
x = Math.min(x, 100);
45
}
47
-
46
t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
47
$[0] = cond;
48
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-recursive-call.expect.md
-1
@@ -37,7 +37,6 @@ function Foo(t0) {
37
return x * factorial(x - 1);
38
}
39
};
40
-
40
t1 = factorial(value);
41
$[0] = value;
42
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-repro-variable-used-in-assignment.expect.md
-1
@@ -30,7 +30,6 @@ function get2() {
30
const copy = x;
31
return copy;
32
};
33
-
33
const x = 2;
34
t0 = callbk();
35
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-setstate-captured-indirectly-jsx.expect.md
-1
@@ -49,7 +49,6 @@ function useFoo() {
49
let t2;
50
if ($[2] !== handleLogout) {
51
const getComponent = () => <ColumnItem onPress={() => handleLogout()} />;
52
-
52
t2 = getComponent();
53
$[2] = handleLogout;
54
$[3] = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-simple-function-expression.expect.md
-2
@@ -30,9 +30,7 @@ function hoisting() {
30
let t0;
31
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32
const foo = () => bar();
33
-
33
const bar = _temp;
35
-
34
t0 = foo();
35
$[0] = t0;
36
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md
-1
@@ -61,7 +61,6 @@ function Component() {
61
let t1;
62
if ($[2] !== state) {
63
const doubledArray = makeArray(state);
64
-
64
t1 = doubledArray.join("");
65
$[2] = state;
66
$[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/idx-no-outlining.expect.md
-1
@@ -29,7 +29,6 @@ function Component(props) {
29
let t0;
30
if ($[0] !== props) {
31
var _ref;
32
-
32
t0 =
33
(_ref = props) != null
34
? (_ref = _ref.group) != null
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md
-1
@@ -30,7 +30,6 @@ function Component(props) {
30
let items;
31
if ($[0] !== props.a || $[1] !== props.cond) {
32
let t0;
33
-
33
if (props.cond) {
34
t0 = [];
35
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/incompatible-destructuring-kinds.expect.md
-1
@@ -34,7 +34,6 @@ function Component(t0) {
34
let t1;
35
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36
a = "a";
37
-
37
const [t2, t3] = [null, null];
38
t1 = t3;
39
a = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-nested-object-method.expect.md
-1
@@ -40,7 +40,6 @@ function Test() {
40
return _temp;
41
},
42
};
43
-
43
t0 = <Stringify value={context} shouldInvokeFns={true} />;
44
$[0] = t0;
45
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked/conditional-call-chain.expect.md
-1
@@ -77,7 +77,6 @@ function Component(t0) {
77
hasLogged.current = true;
78
}
79
};
80
-
80
t3 = <Stringify log={log} shouldInvokeFns={true} />;
81
$[4] = logA;
82
$[5] = logB;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked/use-memo-returned.expect.md
-1
@@ -48,7 +48,6 @@ import { useIdentity } from "shared-runtime";
48
function useMakeCallback(t0) {
49
const $ = _c(2);
50
const { obj, shouldSynchronizeState } = t0;
51
-
51
const [, setState] = useState(0);
52
let t1;
53
if ($[0] !== obj.value) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
-1
@@ -33,7 +33,6 @@ function Component(props) {
33
let t1;
34
if ($[0] !== item) {
35
const count = new MaybeMutable(item);
36
-
36
T1 = View;
37
T0 = View;
38
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md
-1
@@ -25,7 +25,6 @@ function Component(props) {
25
let t0;
26
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
27
const count = new MaybeMutable();
28
-
28
t0 = (
29
<View>
30
<View>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/invalid-set-state-in-effect-verbose-derived-event.expect.md
-1
@@ -42,7 +42,6 @@ function VideoPlayer(t0) {
42
console.log("Play state changed!");
43
}
44
};
45
-
45
t2 = [isPlaying, wasPlaying];
46
$[0] = isPlaying;
47
$[1] = wasPlaying;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/invalid-setState-in-useEffect-transitive.expect.md
-1
@@ -35,7 +35,6 @@ function Component() {
35
const f = () => {
36
setState(_temp);
37
};
38
-
38
t0 = () => {
39
f();
40
};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md
-1
@@ -59,7 +59,6 @@ function Component(props) {
59
if ($[0] !== props.alternateComponent || $[1] !== props.component) {
60
const maybeMutable = new MaybeMutable();
61
Tag = props.component;
62
-
62
T0 = Tag;
63
t0 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
64
$[0] = props.alternateComponent;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-array-access-member-expr-captured.expect.md
-2
@@ -32,9 +32,7 @@ function Foo() {
32
let t0;
33
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34
const x = [{ value: 0 }, { value: 1 }, { value: 2 }];
35
-
35
const foo = () => x[CONST_NUMBER0].value;
37
-
36
t0 = invoke(foo);
37
$[0] = t0;
38
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-array-access-member-expr-param.expect.md
-1
@@ -32,7 +32,6 @@ function Foo() {
32
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
33
const x = [{ value: 0 }, { value: 1 }, { value: 2 }];
34
const foo = (param) => x[param].value;
35
-
35
t0 = invoke(foo, 1);
36
$[0] = t0;
37
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md
-2
@@ -46,12 +46,10 @@ function CaptureNotMutate(props) {
46
let aliasedElement;
47
if ($[2] !== idx || $[3] !== props.el) {
48
const element = bar(props.el);
49
-
49
const fn = function () {
50
const arr = { element };
51
return arr[idx];
52
};
54
-
53
aliasedElement = fn();
54
mutate(aliasedElement);
55
$[2] = idx;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/maybe-mutate-object-in-callback.expect.md
-1
@@ -36,7 +36,6 @@ function Component(props) {
36
let t0;
37
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
38
const object = {};
39
-
39
t0 = () => {
40
mutate(object);
41
};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/multiple-calls-to-hoisted-callback-from-other-callback.expect.md
-3
@@ -43,18 +43,15 @@ function Component(props) {
43
let t0;
44
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
45
const a = () => b();
46
-
46
const b = () => (
47
<>
48
<div onClick={() => onClick(true)}>a</div>
49
<div onClick={() => onClick(false)}>b</div>
50
</>
51
);
53
-
52
const onClick = (value) => {
53
setState(value);
54
};
57
-
55
t0 = <div>{a()}</div>;
56
$[0] = t0;
57
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md
-5
@@ -94,19 +94,14 @@ function testFunction(props) {
94
break;
95
}
96
}
97
-
97
if (a) {
98
}
100
-
99
if (b) {
100
}
103
-
101
if (c) {
102
}
106
-
103
if (d) {
104
}
109
-
105
mutate(d, null);
106
t0 = { a, b, c, d };
107
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md
-1
@@ -74,7 +74,6 @@ function Component(props) {
74
const b = [a];
75
const c = {};
76
const d = { c };
77
-
77
x = {};
78
x.b = b;
79
const y = mutate(x, d);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md
-1
@@ -76,7 +76,6 @@ function useFoo(t0) {
76
let t1;
77
if ($[0] !== input) {
78
const arr = shallowCopy(input);
79
-
79
const cond = identity(false);
80
t1 = cond ? { val: CONST_TRUE } : mutate(arr);
81
$[0] = input;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutation-during-jsx-construction.expect.md
-1
@@ -32,7 +32,6 @@ function Component(props) {
32
let element;
33
if ($[0] !== props.value) {
34
const key = {};
35
-
35
element = <div key={mutateAndReturnNewValue(key)}>{props.value}</div>;
36
37
mutate(key);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutation-within-capture-and-mutablerange.expect.md
-1
@@ -58,7 +58,6 @@ function useFoo(t0) {
58
const x = { a };
59
const y = [b];
60
mutate(x);
61
-
61
z = [mutate(y)];
62
63
mutate(y);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/aliased-nested-scope-truncated-dep.expect.md
-3
@@ -182,12 +182,9 @@ function Component(t0) {
182
if ($[0] !== prop) {
183
const obj = shallowCopy(prop);
184
const aliasedObj = identity(obj);
185
-
185
const id = [obj.id];
187
-
186
mutate(aliasedObj);
187
setPropertyByKey(aliasedObj, "id", prop.id + 1);
190
-
188
t1 = <Stringify id={id} />;
189
$[0] = prop;
190
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/basic-mutation-via-function-expression.expect.md
-1
@@ -31,7 +31,6 @@ function Component(t0) {
31
y.x = x;
32
mutate(y);
33
};
34
-
34
f();
35
t1 = <div>{x}</div>;
36
$[0] = a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/capture-backedge-phi-with-later-mutation.expect.md
-1
@@ -53,7 +53,6 @@ function Component(t0) {
53
let z;
54
if ($[0] !== prop1 || $[1] !== prop2) {
55
let x = [{ value: prop1 }];
56
-
56
while (x.length < 2) {
57
arrayPush(x, { value: prop2 });
58
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/capture-in-function-expression-indirect.expect.md
-1
@@ -48,7 +48,6 @@ function Component(t0) {
48
const b = { x };
49
a.y.x = b;
50
};
51
-
51
f0();
52
mutate(y);
53
t1 = <Stringify x={y} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/iife-return-modified-later-phi.expect.md
-1
@@ -30,7 +30,6 @@ function Component(props) {
30
let items;
31
if ($[0] !== props.a || $[1] !== props.cond) {
32
let t0;
33
-
33
if (props.cond) {
34
t0 = [];
35
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-through-boxing-unboxing-function-call-indirections-2.expect.md
-1
@@ -41,7 +41,6 @@ function Component(t0) {
41
const y = [x];
42
return y[0];
43
};
44
-
44
const x0 = f();
45
const z = [x0];
46
const x1 = z[0];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-through-boxing-unboxing-function-call-indirections.expect.md
-1
@@ -42,7 +42,6 @@ function Component(t0) {
42
const x0 = y[0];
43
return [x0];
44
};
45
-
45
const z = f();
46
const x1 = z[0];
47
x1.key = "value";
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/object-expression-computed-member.expect.md
-1
@@ -32,7 +32,6 @@ function Component(props) {
32
let context;
33
if ($[0] !== props.value) {
34
const key = { a: "key" };
35
-
35
const t0 = key.a;
36
const t1 = identity([props.value]);
37
let t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-function-expression-effects-stack-overflow.expect.md
-1
@@ -45,7 +45,6 @@ function Component() {
45
.build({})
46
.build({});
47
};
48
-
48
t1 = <Stringify x={x} fn={fn} />;
49
$[1] = t1;
50
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-invalid-function-expression-effects-phi.expect.md
-2
@@ -38,10 +38,8 @@ function Component(t0) {
38
while (z == null) {
39
z = x;
40
}
41
-
41
z.y = y;
42
};
44
-
43
f();
44
mutate(x);
45
t1 = <div>{x}</div>;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-jsx-captures-value-mutated-later.expect.md
-3
@@ -33,11 +33,8 @@ function Example() {
33
let t0;
34
if ($[0] !== data) {
35
const { a, b } = identity(data);
36
-
36
const el = <Stringify tooltip={b} />;
38
-
37
identity(a.at(0));
40
-
38
t0 = <Stringify icon={el} />;
39
$[0] = data;
40
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/useCallback-reordering-deplist-controlflow.expect.md
-2
@@ -56,9 +56,7 @@ function Foo(t0) {
56
let t2;
57
if ($[2] !== arr2 || $[3] !== foo || $[4] !== x) {
58
let y = [];
59
-
59
getVal1 = _temp;
61
-
60
t2 = () => [y];
61
foo ? (y = x.concat(arr2)) : y;
62
$[2] = arr2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/object-expression-computed-key-mutate-key-while-constructing-object.expect.md
-1
@@ -30,7 +30,6 @@ function Component(props) {
30
let t0;
31
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32
const key = {};
33
-
33
t0 = mutateAndReturn(key);
34
$[0] = t0;
35
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/object-expression-computed-member.expect.md
-1
@@ -31,7 +31,6 @@ function Component(props) {
31
let context;
32
if ($[0] !== props.value) {
33
const key = { a: "key" };
34
-
34
const t0 = key.a;
35
const t1 = identity([props.value]);
36
let t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md
-1
@@ -27,7 +27,6 @@ function Component(props) {
27
let t0;
28
if ($[0] !== props) {
29
const x = makeOptionalFunction(props);
30
-
30
t0 = x?.(
31
<div>
32
<span>{props.text}</span>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/capture-ref-for-later-mutation.expect.md
-1
@@ -46,7 +46,6 @@ function useKeyCommand() {
46
const nextPosition = direction === "left" ? addOne(position) : position;
47
currentPosition.current = nextPosition;
48
};
49
-
49
const moveLeft = { handler: handleKey("left") };
50
const moveRight = { handler: handleKey("right") };
51
t0 = [moveLeft, moveRight];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-array-push-consecutive-phis.expect.md
-2
@@ -75,9 +75,7 @@ function Component(props) {
75
} else {
76
y = [];
77
}
78
-
78
y.push(x);
80
-
79
t1 = [x, y];
80
$[1] = props.cond;
81
$[2] = props.cond2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-array-push.expect.md
-2
@@ -53,9 +53,7 @@ function Component(props) {
53
} else {
54
y = [];
55
}
56
-
56
y.push(x);
58
-
57
t1 = [x, y];
58
$[1] = props.cond;
59
$[2] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-property-store.expect.md
-2
@@ -49,9 +49,7 @@ function Component(props) {
49
} else {
50
y = { a: props.a };
51
}
52
-
52
y.x = x;
54
-
53
t1 = [x, y];
54
$[1] = props.a;
55
$[2] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/prune-nonescaping-useMemo-mult-returns-primitive.expect.md
-1
@@ -34,7 +34,6 @@ import { identity } from "shared-runtime";
34
35
function useFoo(cond) {
36
let t0;
37
-
37
if (cond) {
38
t0 = 2;
39
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/prune-nonescaping-useMemo-mult-returns.expect.md
-1
@@ -34,7 +34,6 @@ import { identity } from "shared-runtime";
34
35
function useFoo(cond) {
36
let t0;
37
-
37
if (cond) {
38
t0 = identity(10);
39
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-in-other-reactive-block.expect.md
-1
@@ -52,7 +52,6 @@ function useFoo(minWidth, otherProp) {
52
t1 = $[6];
53
}
54
const style = t1;
55
-
55
arrayPush(x, otherProp);
56
t0 = [style, x];
57
$[0] = minWidth;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-reordering-deplist-controlflow.expect.md
-2
@@ -56,9 +56,7 @@ function Foo(t0) {
56
let t2;
57
if ($[2] !== arr2 || $[3] !== foo || $[4] !== x) {
58
let y = [];
59
-
59
getVal1 = _temp;
61
-
60
t2 = () => [y];
61
foo ? (y = x.concat(arr2)) : y;
62
$[2] = arr2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-in-other-reactive-block.expect.md
-2
@@ -42,7 +42,6 @@ function useFoo(minWidth, otherProp) {
42
let t0;
43
if ($[0] !== minWidth || $[1] !== otherProp || $[2] !== width) {
44
const x = [];
45
-
45
const t1 = Math.max(minWidth, width);
46
let t2;
47
if ($[4] !== t1) {
@@ -53,7 +52,6 @@ function useFoo(minWidth, otherProp) {
52
t2 = $[5];
53
}
54
const style = t2;
56
-
55
arrayPush(x, otherProp);
56
t0 = [style, x];
57
$[0] = minWidth;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-reordering-depslist-controlflow.expect.md
-1
@@ -47,7 +47,6 @@ function Foo(t0) {
47
let val1;
48
if ($[0] !== arr1 || $[1] !== arr2 || $[2] !== foo) {
49
const x = [arr1];
50
-
50
let y = [];
51
let t2;
52
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.expect.md
-4
@@ -45,11 +45,9 @@ function ComponentA(props) {
45
if (b) {
46
a.push(props.p0);
47
}
48
-
48
if (props.p1) {
49
b.push(props.p2);
50
}
52
-
51
t0 = <Foo a={a} b={b} />;
52
$[0] = props.p0;
53
$[1] = props.p1;
@@ -70,11 +68,9 @@ function ComponentB(props) {
68
if (mayMutate(b)) {
69
a.push(props.p0);
70
}
73
-
71
if (props.p1) {
72
b.push(props.p2);
73
}
77
-
74
t0 = <Foo a={a} b={b} />;
75
$[0] = props.p0;
76
$[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/iife-return-modified-later-phi.expect.md
-1
@@ -31,7 +31,6 @@ function Component(props) {
31
let items;
32
if ($[0] !== props.a || $[1] !== props.cond) {
33
let t0;
34
-
34
if (props.cond) {
35
t0 = [];
36
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/infer-component-props-non-null.expect.md
-1
@@ -47,7 +47,6 @@ function Foo(props) {
47
}
48
arr.push(t1);
49
}
50
-
50
t0 = <Stringify arr={arr} />;
51
$[0] = props.cond;
52
$[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push-consecutive-phis.expect.md
-2
@@ -76,9 +76,7 @@ function Component(props) {
76
} else {
77
y = [];
78
}
79
-
79
y.push(x);
81
-
80
t1 = [x, y];
81
$[1] = props.cond;
82
$[2] = props.cond2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push.expect.md
-2
@@ -54,9 +54,7 @@ function Component(props) {
54
} else {
55
y = [];
56
}
57
-
57
y.push(x);
59
-
58
t1 = [x, y];
59
$[1] = props.cond;
60
$[2] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-property-store.expect.md
-2
@@ -49,9 +49,7 @@ function Component(props) {
49
} else {
50
y = { a: props.a };
51
}
52
-
52
y.x = x;
54
-
53
t1 = [x, y];
54
$[1] = props.a;
55
$[2] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reduce-reactive-deps/infer-nested-function-uncond-access.expect.md
-1
@@ -36,7 +36,6 @@ function useFoo(t0) {
36
let t1;
37
if ($[0] !== a.b.c) {
38
const fn = () => () => ({ value: a.b.c });
39
-
39
t1 = <Stringify fn={fn} shouldInvokeFns={true} />;
40
$[0] = a.b.c;
41
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reduce-reactive-deps/join-uncond-scopes-cond-deps.expect.md
-1
@@ -71,7 +71,6 @@ function useJoinCondDepsInUncondScopes(props) {
71
if (CONST_TRUE) {
72
setProperty(x, props.a.b);
73
}
74
-
74
setProperty(y, props.a.b);
75
t0 = [x, y];
76
$[0] = props.a.b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/ssa-leave-case.expect.md
-1
@@ -49,7 +49,6 @@ function Component(props) {
49
x.push(props.p1);
50
y = x;
51
}
52
-
52
t0 = (
53
<Stringify>
54
{x}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/switch.expect.md
-1
@@ -34,7 +34,6 @@ function Component(props) {
34
let y;
35
if ($[0] !== props.p0 || $[1] !== props.p2 || $[2] !== props.p3) {
36
const x = [];
37
-
37
switch (props.p0) {
38
case true: {
39
x.push(props.p2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/prune-scopes-whose-deps-invalidate-jsx.expect.md
-1
@@ -45,7 +45,6 @@ function Component(props) {
45
let t1;
46
if ($[2] !== x) {
47
const y = <div>{x}</div>;
48
-
48
t1 = <div>{y}</div>;
49
$[2] = x;
50
$[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/prune-scopes-whose-deps-may-invalidate-array.expect.md
-1
@@ -42,7 +42,6 @@ function Component(props) {
42
let t0;
43
if ($[0] !== x) {
44
const y = [x];
45
-
45
t0 = [y];
46
$[0] = x;
47
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-dependency-object-captured-with-reactive-mutated.expect.md
-1
@@ -34,7 +34,6 @@ function Component(props) {
34
const y = props.y;
35
const z = [x, y];
36
mutate(z);
37
-
37
t0 = [x];
38
$[0] = props.y;
39
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-scopes.expect.md
-1
@@ -35,7 +35,6 @@ function f(a, b) {
35
x.push(b);
36
}
37
}
38
-
38
t0 = <div>{x}</div>;
39
$[0] = a.length;
40
$[1] = b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md
-2
@@ -42,9 +42,7 @@ function Component(props) {
42
const b = [];
43
b.push(props.b);
44
a.a = null;
45
-
45
const c = [a];
47
-
46
t0 = [c, a];
47
$[0] = props.b;
48
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassign-in-while-loop-condition.expect.md
-1
@@ -39,7 +39,6 @@ function Component() {
39
while ((item = items.pop())) {
40
sum = sum + item;
41
}
42
-
42
t0 = [items, sum];
43
$[0] = t0;
44
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md
-3
@@ -29,7 +29,6 @@ function Component(props) {
29
let x = [];
30
x.push(props.p0);
31
const y = x;
32
-
32
if (props.p1) {
33
let t1;
34
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
@@ -40,9 +39,7 @@ function Component(props) {
39
}
40
x = t1;
41
}
43
-
42
y.push(props.p2);
45
-
43
t0 = <Component x={x} y={y} />;
44
$[0] = props.p0;
45
$[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md
-1
@@ -49,7 +49,6 @@ function foo(a, b, c) {
49
if (a) {
50
x.push(a);
51
}
52
-
52
t0 = <div>{x}</div>;
53
$[0] = a;
54
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment.expect.md
-2
@@ -36,9 +36,7 @@ function Component(props) {
36
t1 = $[3];
37
}
38
x = t1;
39
-
39
y.push(props.p1);
41
-
40
t0 = <Component x={x} y={y} />;
41
$[0] = props.p0;
42
$[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/recursive-function-expression.expect.md
-1
@@ -62,7 +62,6 @@ function Component() {
62
}
63
return callback(x - 1);
64
}
65
-
65
t0 = callback(10);
66
$[0] = t0;
67
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/join-uncond-scopes-cond-deps.expect.md
-1
@@ -69,7 +69,6 @@ function useJoinCondDepsInUncondScopes(props) {
69
if (CONST_TRUE) {
70
setProperty(x, props.a.b);
71
}
72
-
72
setProperty(y, props.a.b);
73
t0 = [x, y];
74
$[0] = props.a.b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-aliased-no-added-to-dep.expect.md
-1
@@ -28,7 +28,6 @@ function VideoTab() {
28
const x = () => {
29
console.log(t);
30
};
31
-
31
t0 = <VideoList videos={x} />;
32
$[0] = t0;
33
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-aliased-not-added-to-dep-2.expect.md
-1
@@ -25,7 +25,6 @@ function Foo(t0) {
25
let t1;
26
if ($[0] !== a) {
27
const x = { a, val };
28
-
28
t1 = <VideoList videos={x} />;
29
$[0] = a;
30
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-field-not-added-to-dep.expect.md
-1
@@ -26,7 +26,6 @@ function VideoTab() {
26
const x = () => {
27
console.log(ref.current.x);
28
};
29
-
29
t0 = <VideoList videos={x} />;
30
$[0] = t0;
31
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-field-write-not-added-to-dep.expect.md
-1
@@ -41,7 +41,6 @@ function Component() {
41
const inputChanged = (e) => {
42
ref.current.text.value = e.target.value;
43
};
44
-
44
t1 = <input onChange={inputChanged} />;
45
$[1] = t1;
46
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep-2.expect.md
-1
@@ -23,7 +23,6 @@ function Foo(t0) {
23
let t1;
24
if ($[0] !== a) {
25
const x = { a, val: ref.current };
26
-
26
t1 = <VideoList videos={x} />;
27
$[0] = a;
28
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep.expect.md
-1
@@ -25,7 +25,6 @@ function VideoTab() {
25
const x = () => {
26
console.log(ref.current);
27
};
28
-
28
t0 = <VideoList videos={x} />;
29
$[0] = t0;
30
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-optional-field-no-added-to-dep.expect.md
-1
@@ -25,7 +25,6 @@ function VideoTab() {
25
const x = () => {
26
ref.current?.x;
27
};
28
-
28
t0 = <VideoList videos={x} />;
29
$[0] = t0;
30
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-write-not-added-to-dep.expect.md
-1
@@ -25,7 +25,6 @@ function VideoTab() {
25
const x = () => {
26
ref.current = 1;
27
};
28
-
28
t0 = <VideoList videos={x} />;
29
$[0] = t0;
30
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/regexp-literal.expect.md
-1
@@ -26,7 +26,6 @@ function Component(props) {
26
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
27
const pattern = /foo/g;
28
value = makeValue();
29
-
29
t0 = pattern.test(value);
30
$[0] = t0;
31
$[1] = value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rename-source-variables-nested-function.expect.md
-1
@@ -57,7 +57,6 @@ function useFoo(props) {
57
};
58
return b;
59
};
60
-
60
t1 = a()()();
61
$0[0] = props.value;
62
$0[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-aliased-capture-aliased-mutate.expect.md
-1
@@ -73,7 +73,6 @@ function useFoo(t0) {
73
if ($[0] !== a || $[1] !== b) {
74
const x = [];
75
const y = { value: a };
76
-
76
arrayPush(x, y);
77
const y_alias = y;
78
const cb = () => y_alias.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-aliased-capture-mutate.expect.md
-2
@@ -54,14 +54,12 @@ function useFoo(t0) {
54
if ($[0] !== a) {
55
const arr = [];
56
const obj = { value: a };
57
-
57
setPropertyByKey(obj, "arr", arr);
58
const obj_alias = obj;
59
const cb = () => obj_alias.arr.length;
60
for (let i = 0; i < a; i++) {
61
arr.push(i);
62
}
64
-
63
t1 = <Stringify cb={cb} shouldInvokeFns={true} />;
64
$[0] = a;
65
$[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-false-positive-ref-validation-in-use-effect.expect.md
-1
@@ -68,7 +68,6 @@ function Component() {
68
update();
69
}
70
};
71
-
71
t2 = [update];
72
$[2] = update;
73
$[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-independently-memoized-property-load-for-method-call.expect.md
-3
@@ -61,11 +61,8 @@ function Component(t0) {
61
let timestampLabel;
62
if ($[0] !== highlightedItem || $[1] !== label || $[2] !== serverTime) {
63
const highlight = new Highlight(highlightedItem);
64
-
64
const time = serverTime.get();
66
-
65
timestampLabel = time / 1000 || label;
68
-
66
t1 = highlight.render();
67
$[0] = highlightedItem;
68
$[1] = label;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-instruction-part-of-already-closed-scope.expect.md
-1
@@ -46,7 +46,6 @@ function Component(t0) {
46
const a = identity(data, index);
47
const b = identity(data, index);
48
const c = identity(data, index);
49
-
49
const t4 = identity(b);
50
if ($[6] !== t4) {
51
t2 = <Stringify value={t4} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-missing-dependency-if-within-while.expect.md
-1
@@ -51,7 +51,6 @@ export default function Component(props) {
51
i++;
52
}
53
}
54
-
54
t0 = <>{items}</>;
55
$[0] = b;
56
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-ref-in-function-passed-to-hook.expect.md
-1
@@ -89,7 +89,6 @@ function Example() {
89
observer.disconnect();
90
};
91
};
92
-
92
t3 = [];
93
$[2] = t2;
94
$[3] = t3;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-result-of-function-call-with-frozen-argument-in-function-expression.expect.md
-1
@@ -39,7 +39,6 @@ function Example(props) {
39
obj.property = props.value;
40
return obj;
41
};
42
-
42
t0 = f();
43
$[0] = object;
44
$[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-result-of-method-call-on-frozen-value-in-function-expression.expect.md
-1
@@ -39,7 +39,6 @@ function Example(props) {
39
obj.property = props.value;
40
return obj;
41
};
42
-
42
t0 = f();
43
$[0] = object;
44
$[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-declarations-in-reactive-scope-with-early-return.expect.md
-1
@@ -62,7 +62,6 @@ function Component() {
62
t1 = t2;
63
break bb0;
64
}
65
-
65
t0 = filteredItems.map(_temp2);
66
}
67
$[0] = items;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-value-for-temporary-reactive-scope-with-early-return.expect.md
-1
@@ -50,7 +50,6 @@ function Component(props) {
50
t1 = null;
51
break bb0;
52
}
53
-
53
t0 = (
54
<div className="foo">
55
{fbt._(
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md
-1
@@ -57,7 +57,6 @@ function Component(props) {
57
t1 = null;
58
break bb0;
59
}
60
-
60
t0 = identity(propsString);
61
}
62
$[0] = props;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.expect.md
-1
@@ -63,7 +63,6 @@ function Foo(t0) {
63
obj.value = newValue;
64
obj.a = a;
65
};
66
-
66
const updater = updaterFactory();
67
updater(b);
68
t1 = <Stringify cb={obj} shouldInvokeFns={true} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.expect.md
-1
@@ -61,7 +61,6 @@ function Foo(t0) {
61
const fnFactory = () => () => {
62
myVar = _temp;
63
};
64
-
64
let myVar = _temp2;
65
useIdentity();
66
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md
-2
@@ -53,9 +53,7 @@ function Component(props) {
53
let t0;
54
if ($[0] !== buttons) {
55
const [, ...nonPrimaryButtons] = buttons;
56
-
56
const renderedNonPrimaryButtons = nonPrimaryButtons.map(_temp);
58
-
57
t0 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
58
$[0] = buttons;
59
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-unmerged-fbt-call-merge-overlapping-reactive-scopes.expect.md
-1
@@ -44,7 +44,6 @@ function Component(props) {
44
[fbt._plural(props.value.length, "number")],
45
{ hk: "4mUen7" },
46
);
47
-
47
t0 = props.cond ? (
48
<Stringify
49
description={fbt._("Text here", null, { hk: "21YpZs" })}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md
-1
@@ -58,7 +58,6 @@ function foo(props) {
58
if ($[0] !== props.a) {
59
x = [];
60
x.push(props.a);
61
-
61
t0 = <div>{x}</div>;
62
$[0] = props.a;
63
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md
-1
@@ -50,7 +50,6 @@ function Component(statusName) {
50
const { status, text: t2 } = foo(statusName);
51
text = t2;
52
const { bg, color } = getStyles(status);
53
-
53
t1 = identity(bg);
54
t0 = identity(color);
55
$[0] = statusName;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md
-2
@@ -52,10 +52,8 @@ function Component(statusName) {
52
if ($[0] !== statusName) {
53
const { status, text: t1 } = foo(statusName);
54
text = t1;
55
-
55
const { color, font: t2 } = getStyles(status);
56
font = t2;
58
-
57
t0 = identity(color);
58
$[0] = statusName;
59
$[1] = font;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md
-1
@@ -33,7 +33,6 @@ function Component(props) {
33
foo(a, b);
34
if (foo()) {
35
}
36
-
36
foo(a, b);
37
t0 = <div a={a} b={b} />;
38
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md
-1
@@ -28,7 +28,6 @@ function Component(props) {
28
const a = [];
29
const b = {};
30
foo(a, b);
31
-
31
foo(a, b);
32
t0 = <div a={a} b={b} />;
33
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md
-1
@@ -48,7 +48,6 @@ function Component(props) {
48
x.push(props.p1);
49
y = x;
50
}
51
-
51
t0 = (
52
<Stringify>
53
{x}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md
-1
@@ -25,7 +25,6 @@ function foo() {
25
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
26
const a = {};
27
const x = a;
28
-
28
y = {};
29
y.x = x;
30
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/static-components/invalid-dynamically-constructed-component-function.expect.md
-1
@@ -23,7 +23,6 @@ function Example(props) {
23
const Component = function Component() {
24
return <div />;
25
};
26
-
26
t0 = <Component />;
27
$[0] = t0;
28
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/switch.expect.md
-1
@@ -33,7 +33,6 @@ function Component(props) {
33
let y;
34
if ($[0] !== props.p0 || $[1] !== props.p2 || $[2] !== props.p3) {
35
const x = [];
36
-
36
switch (props.p0) {
37
case true: {
38
x.push(props.p2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-function-expression-captures-value-later-frozen.expect.md
-3
@@ -28,14 +28,11 @@ function Component(props) {
28
let t0;
29
if ($[0] !== props.cond) {
30
const x = {};
31
-
31
const onChange = (e) => {
32
maybeMutate(x, e.target.value);
33
};
35
-
34
if (props.cond) {
35
}
38
-
36
onChange();
37
t0 = <Foo value={x} />;
38
$[0] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-global-property-load-cached.expect.md
-1
@@ -45,7 +45,6 @@ function Component(t0) {
45
let t1;
46
if ($[0] !== num) {
47
const arr = makeArray(num);
48
-
48
T0 = SharedRuntime.Stringify;
49
t1 = arr.push(num);
50
$[0] = num;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transitive-freeze-array.expect.md
-1
@@ -36,7 +36,6 @@ function Component(props) {
36
const y = {};
37
const items = [x, y];
38
items.pop();
39
-
39
mutate(y);
40
t0 = [x, y, items];
41
$[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md
-1
@@ -59,7 +59,6 @@ function Component(props) {
59
if (isLoadingNext) {
60
return;
61
}
62
-
62
loadMoreWithTiming();
63
};
64
t2 = [isLoadingNext, loadMoreWithTiming];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-within-function-expression-returns-caught-value.expect.md
-1
@@ -40,7 +40,6 @@ function Component(props) {
40
return e;
41
}
42
};
43
-
43
t0 = callback();
44
$[0] = props;
45
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md
-1
@@ -29,7 +29,6 @@ function component() {
29
let x;
30
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31
const o = {};
32
-
32
x = {};
33
34
x.t = p;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useActionState-dispatch-considered-as-non-reactive.expect.md
-1
@@ -35,7 +35,6 @@ function Component() {
35
const onSubmitAction = () => {
36
dispatchAction();
37
};
38
-
38
t0 = <Foo onSubmitAction={onSubmitAction} />;
39
$[0] = t0;
40
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useContext-read-context-in-callback-if-condition.expect.md
-1
@@ -50,7 +50,6 @@ function Component(props) {
50
return null;
51
}
52
};
53
-
53
t0 = getValue();
54
$[0] = foo.current;
55
$[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useReducer-returned-dispatcher-is-non-reactive.expect.md
-1
@@ -36,7 +36,6 @@ function f() {
36
const onClick = () => {
37
dispatch();
38
};
39
-
39
t0 = <div onClick={onClick} />;
40
$[0] = t0;
41
} else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/valid-setState-in-effect-from-ref-function-call.expect.md
-1
@@ -50,7 +50,6 @@ function Component() {
50
}
51
return 100;
52
};
53
-
53
setWidth(getBoundingRect(ref));
54
};
55
t1 = [];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/valid-setState-in-useEffect-controlled-by-ref-value.expect.md
-1
@@ -71,7 +71,6 @@ function Component(t0) {
71
setData(data_0);
72
}
73
};
74
-
74
t2 = [x, y];
75
$[0] = x;
76
$[1] = y;