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
This is working as intended. We complain about arr having an implicit any[] type because it is possible for control to reach the arr.some(...) call before any elements have been added to the array. It's equivalent to what happens in this example:
consta=[];if(!a.some(x=>x==='foo')){// Error, a implicitly has type any[]a.push('bar');}
Now, you could argue that the implicit any types don't matter because when the array is empty the arrow function is never called. But that's only because we know the semantics of the some method. It's not a general assumption we can make.
Expected: The type of
arr
isstring[]
.Actual: An error under
noImplicitAny
.Playground Link
Originally found in #45117, reported by @mkubilayk.
The text was updated successfully, but these errors were encountered: