Correct usage of Iterator and Iterable interfaces #1425
Labels
resolution:expired
This issue was closed due to lack of feedback.
status:discussion
status:stale
type:docs
This issue reports a task related to documentation (e.g. an idea for a guide).
As a follow-up to the #755 issue, we need to fix incorrect usages of these interfaces. If we go someday with the #1415 it will save us some time in fixing it anyway (TS is very accurate in the checking these interfaces). And it's easier to fix bugs in small PRs.
First of all, I'd redefine a little bit the rule that's in the #755 (comment).
Use the
Iterable
interface for classes that implement the[Symbol.iterator]()
method.Use the
Iterable
interface for function / method paremeter types. Unless you're sure that the function takes theIterator
(like thefirst( iterator )
function inckeditor5-utils
).Use the
Iterable
interface for generators. They implement actually theIterableIterator
interface, but we don't use the code in such a way AFAIK, so it should be safe.Use the
Iterator
interface as a return type of the[Symbol.iterator]()
method.Use the
Iterator
interface for custom iterators.The text was updated successfully, but these errors were encountered: