Skip to content

Fix interface definition of Generator object. It should extend IterableIterator<T> #29562

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

Closed

Conversation

darcyparker
Copy link

The current definition is incomplete. It is both an Iterator and Iterable.

Also see #2873 (comment):

  • "This has been revised: IterableIterator must be assignable to the type annotation instead."

  • It references another pull request Basic support for generators as iterators #3031 which notes it should be IterableIterator<T>, but it neglected to update the type definitions for lib.es2015.generator.d.ts and es2015.generator.d.ts.

@@ -18,19 +18,19 @@ and limitations under the License.
/// <reference no-default-lib="true"/>


interface Generator extends Iterator<any> { }
interface Generator<T> extends IterableIterator<T> { }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about requiring all fields of the Iterator object?

Suggested change
interface Generator<T> extends IterableIterator<T> { }
interface Generator<T> extends Required<IterableIterator<T>> { }

The return and throw methods should not be optional as defined in the ECMAScript 2015 Language Specification. This would close #21527.

@rbuckton
Copy link
Member

rbuckton commented May 7, 2019

I am closing this PR as we are completely rewriting the Generator interface in #30790, which supercedes this change.

@rbuckton rbuckton closed this May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants