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
.get(someString) from the perspective of the compiler is just another method call. Thereβs no way for it to know it returns the same result every time. So you canβt narrow it that way, and I probably wouldnβt write the code this way anyway. Call .get() once, assign the result to a variable, and narrow that.
+1 to the above comment. I'm not even sure given the capability, we would do it -Maps are mutable and the key being there on one call isn't a guarantee it's there in another call. FWIW there's another open feature request which I can't find (because the keywords are useless) about using has as a narrowing method for subsequent get calls.
π Search Terms
map containing array may be null or undefined
π Version & Regression Information
This is the current behavior even in 5.5.1-rc
β― Playground Link
No response
π» Code
π Actual behavior
Compiler complains that the result of the Map.get operation could be null or undefined
π Expected behavior
The null and undefined check should be recognized as ensuring that the Map.get operation does not return a null or undefined.
Additional information about the issue
I posted a similar issue recently about multidimensional arrays, but that was solved by 5.5.0 beta/5.5.1-rc. This problem is not solved by them.
The text was updated successfully, but these errors were encountered: