Skip to content

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.



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
Contributor

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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants