Repro for uninitialized value due to shadowed function name

This commit is contained in:
Joe Savona
2024-03-21 14:11:06 -07:00
parent a6b3adbe68
commit 1b6afa1879
2 changed files with 40 additions and 0 deletions
@@ -0,0 +1,30 @@
## Input
```javascript
function Component(props) {
function hasErrors() {
let hasErrors = false;
if (props.items == null) {
hasErrors = true;
}
return hasErrors;
}
return hasErrors();
}
```
## Error
```
7 | return hasErrors;
8 | }
> 9 | return hasErrors();
| ^^^^^^^^^ [ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. hasErrors_0$16 (9:9)
10 | }
11 |
```
@@ -0,0 +1,10 @@
function Component(props) {
function hasErrors() {
let hasErrors = false;
if (props.items == null) {
hasErrors = true;
}
return hasErrors;
}
return hasErrors();
}