-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS2495: Type 'ArrayLike<T>' is not an array type or string type. #20852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It definitely should not work for any ES target. It may happen to work if you are using typescript with downlevel iteration disabled, but that is a deliberate spec violation in the name of compatibility with old, non-polyfilled browsers. The right hand side of EDIT: which means the message probably should be changed to say that the type is not |
@Kovensky If you look at |
yes, but
If you do want to iterate over any |
Sorry still trying to wrap my head around why this is a thing. Since the underlying JS code will work, just as it does with an array. So instead of an efficient Maybe it's just my opinion, but this seems overly strict. And I normally prefer strict. :| |
for(let x of <ArrayLike<T>>source) { } Can you provide a type alternative to |
Looks like a duplicate of #2862. |
Seems dupe-enough, but I still feel left uneasy because |
Error:
TS2495: Type 'ArrayLike<T>' is not an array type or string type.
Why is this a thing? A for loop using
ArrayLike<T>
as a source should work for any ES target.TS 2.6.1
The text was updated successfully, but these errors were encountered: