You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letfoo=false;[1,2,3].map(()=>{foo=true;});typeFoo=typeoffoo;// Foo resolves to `false`
🙁 Actual behavior
Foo resolved to false, even though the runtime value is true
🙂 Expected behavior
Foo should resolve to boolean - since TypeScript does not intrinsically know if a callback will be called immediately or asynchronously.
The text was updated successfully, but these errors were encountered:
bluepnume
changed the title
Immediately-executed callback function not considered when evaluating type.
Immediately-executed callback function not considered when refining type.
Jan 27, 2023
Bug Report
Ideally
Foo
should resolve toboolean
here🔎 Search Terms
typescript immedately executed callback refine type
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Foo
resolved tofalse
, even though the runtime value istrue
🙂 Expected behavior
Foo
should resolve toboolean
- since TypeScript does not intrinsically know if a callback will be called immediately or asynchronously.The text was updated successfully, but these errors were encountered: