Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ fn get_context_reassignment(
}),
);
// Return null (don't propagate further) — matches TS behavior
return None;
} else {
// Propagate reassignment info on the lvalue
reassigning_functions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

## Input

```javascript
function Component() {
let value: number | undefined;
const a = async () => {
value = 1;
};
const b = async () => {
value = 2;
};
return <div>{[a, b]}</div>;
}

```


## Error

```
Found 1 error:

Error: Cannot reassign variable in async function

Reassigning a variable in an async function can cause inconsistent behavior on subsequent renders. Consider using state instead.

error.invalid-reassign-local-variable-in-multiple-async-callbacks.ts:4:2
2 | let value: number | undefined;
3 | const a = async () => {
> 4 | value = 1;
| ^^^^^ Cannot reassign `value`
5 | };
6 | const b = async () => {
7 | value = 2;
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Component() {
let value: number | undefined;
const a = async () => {
value = 1;
};
const b = async () => {
value = 2;
};
return <div>{[a, b]}</div>;
}
Loading