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
Some code flows like functions passed to array methods are not considered as immediately invoked and any assignment to a variable inside the array methods are not captured in the outer scope.
letmap: Map<string,string>|null=null;[1].map(()=>{map=newMap()});if(map!=null){// map is neverconsole.log(map.get("something"));}
🙁 Actual behavior
In the above code, after the null check, the variable map is expected to be of type Map<string,string>, but the assignment inside the Array.map function isn't captured and is considered as never.
Property 'get' does not exist on type 'never'.(2339)
🙂 Expected behavior
The variable map is of the type Map<string, string>
The text was updated successfully, but these errors were encountered:
Bug Report
Some code flows like functions passed to array methods are not considered as immediately invoked and any assignment to a variable inside the array methods are not captured in the outer scope.
For example,
🔎 Search Terms
array methods, never, null check, assignment, variable assignment
🕗 Version & Regression Information
4.3.2
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
In the above code, after the null check, the variable
map
is expected to be of typeMap<string,string>
, but the assignment inside theArray.map
function isn't captured and is considered asnever
.🙂 Expected behavior
The variable
map
is of the typeMap<string, string>
The text was updated successfully, but these errors were encountered: