menu
no-explicit-iterator-in-for-of
Disallow explicit iterator calls in for-of loops
A for-of loop obtains an iterable's iterator automatically. Instead, you SHOULD iterate over the iterable directly.
Reported
1function sum(values: int32[]): int32 {2 let total: int32 = 0;3 for (const value of values.iterator()) {4 total += value;5 }6 return total;7}Accepted
1function sum(values: int32[]): int32 {2 let total: int32 = 0;3 for (const value of values) {4 total += value;5 }6 return total;7}