⚙ Compilation target
ESNext
⚙ Library
esnext.iterator.d.ts
Missing / Incorrect Definition
Sample Code
https://github.com/nikolaybotev/iteratorhelpersdemo
Documentation Link
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator
and
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
⚙ Compilation target
ESNext
⚙ Library
esnext.iterator.d.ts
Missing / Incorrect Definition
Iterator.from(value: Iterator)- PR Improve generic type signature of Iterator.from() #59927this is a bad idea; my mistakevalueiterator argument withTNextother thanundefinedshould be accepted;IteratorObjectinstances (objects whose prototype isIterator.prototype) are not wrapped byIterator.from, we could add anIterator.fromoverload to represent those cases and pass through all generic type parameters:from<T, TReturn = any, TNext = any>(value: IteratorObject<T, TReturn, TNext>): IteratorObject<T, TReturn, TNext>;TReturntype should be passed through from the argument to the return typefilter,mapetc) do not propagate the return value of their source iterator and should haveTReturnset toundefinedIterator objects returned fromthanks to @bakkot for the clarificationIterator.fromand the other built-in iterators returned fromArray.valuesetc always have areturnmethod (built-in iterators returned fromArray.valuesetc also always have athrowmethod)IteratorObjectwithout also forcing user-defined classes extending from the javascriptIteratorclass to also implement thereturnmethod, which would be wrong. The impact on client code is minimal as the Iterator object'sreturnmethod can always be called safely using thereturn!()notation.Sample Code
https://github.com/nikolaybotev/iteratorhelpersdemoDocumentation Link
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator
and
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols