@samitouri / QOS-React-1 / commits / 73fa712108

Repro for destructuring with partial context variables

Joe Savona committed Mar 22, 2024 at 14:32 UTC 73fa712108dcd7b1a103291650087f561be613b4
2 files changed +49
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.expect.md new
+35
@@ -0,0 +1,35 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import { useMemo } from "react";
6 +import { Stringify } from "shared-runtime";
7 +
8 +function Component({}) {
9 + let a = "a";
10 + let b = "";
11 + [a, b] = [null, null];
12 + return <Stringify a={a} b={b} onClick={() => a} />;
13 +}
14 +
15 +export const FIXTURE_ENTRYPOINT = {
16 + fn: Component,
17 + params: [{}],
18 +};
19 +
20 +```
21 +
22 +
23 +## Error
24 +
25 +```
26 + 5 | let a = "a";
27 + 6 | let b = "";
28 +> 7 | [a, b] = [null, null];
29 + | ^ [ReactForget] Invariant: Expected consistent kind for destructuring. Other places were 'Const' but 'store b$36[10:12]' is reassigned (7:7)
30 + 8 | return <Stringify a={a} b={b} onClick={() => a} />;
31 + 9 | }
32 + 10 |
33 +```
34 +
35 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.js new
+14
@@ -0,0 +1,14 @@
1 +import { useMemo } from "react";
2 +import { Stringify } from "shared-runtime";
3 +
4 +function Component({}) {
5 + let a = "a";
6 + let b = "";
7 + [a, b] = [null, null];
8 + return <Stringify a={a} b={b} onClick={() => a} />;
9 +}
10 +
11 +export const FIXTURE_ENTRYPOINT = {
12 + fn: Component,
13 + params: [{}],
14 +};