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
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
Related to #2927 and basically a duplicate of #2021
Probably flag may be added to suggest for..of only for arrays/strings.
That would require the rule to use the type checker. If it's a type checked rule, we could instead check if --downlevelIteration is enabled or target >= ES6 in tsconfig.json and lint according to that setting. That wouldn't require a new option and you don't have to keep your configs in sync.
Unfortunately TypeChecker does not expose isArrayLikeType which would be needed to correctly implement this. Note that no-for-in-array currently has the same limitations: doesn't handle ReadonlyArray or shadowing the type Array
Exposing the necessary API(s) is tracked by microsoft/TypeScript#9879, microsoft/TypeScript#17680 and many other issues
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
ERROR: test.ts[3, 3]: Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
Expected behavior
No error.. you can't use for-of loops on Uint8Array or any Typed Arrays.
The text was updated successfully, but these errors were encountered: