mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[test] Add failing test of incorrect typing of captured ref
The typer doesn't understand that it needs to ignore captured references ("read"
refs are ok, but not "mutated" refs) to be conservative.
This commit is contained in:
1 parent
ec2a179572
commit
d24f3fdad9
2 files changed
+40
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component(a) {
|
||||
let x = { a };
|
||||
let y = 1;
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
mutate(y);
|
||||
return y;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component(a) {
|
||||
const x = { a: a };
|
||||
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
mutate(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
function component(a) {
|
||||
let x = { a };
|
||||
let y = 1;
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
mutate(y);
|
||||
return y;
|
||||
}
|
||||
Reference in new issue
Block a user