mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[test] Fix test to have initial value
Having undefined as the initial value makes this a primitive. There's a separate bug where we need to remove type inference for captured refs that get mutated but that's secondary -- we're currently not even marking the Identifier LHS as a captured ref. Fix the test to repro this bug for now.
This commit is contained in:
+16
-8
@@ -4,7 +4,7 @@
|
||||
```javascript
|
||||
function component(a) {
|
||||
let x = { a };
|
||||
let y;
|
||||
let y = {};
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
@@ -18,7 +18,7 @@ function component(a) {
|
||||
|
||||
```javascript
|
||||
function component(a) {
|
||||
const $ = React.unstable_useMemoCache(2);
|
||||
const $ = React.unstable_useMemoCache(4);
|
||||
const c_0 = $[0] !== a;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
@@ -29,12 +29,20 @@ function component(a) {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
mutate(undefined);
|
||||
return undefined;
|
||||
const c_2 = $[2] !== x;
|
||||
let y;
|
||||
if (c_2) {
|
||||
y = {};
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
mutate(y);
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
} else {
|
||||
y = $[3];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function component(a) {
|
||||
let x = { a };
|
||||
let y;
|
||||
let y = {};
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user