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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/lib.es2015.generator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.


interface GeneratorFunction {
interface GeneratorFunction<T> {
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
new (...args: any[]): Generator;
new (...args: any[]): Generator<T>;
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
(...args: any[]): Generator;
(...args: any[]): Generator<T>;
/**
* The length of the arguments.
*/
Expand All @@ -42,20 +42,20 @@ interface GeneratorFunction {
/**
* A reference to the prototype.
*/
readonly prototype: Generator;
readonly prototype: Generator<T>;
}

interface GeneratorFunctionConstructor {
interface GeneratorFunctionConstructor<T> {
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
new (...args: string[]): GeneratorFunction;
new (...args: string[]): GeneratorFunction<T>;
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
(...args: string[]): GeneratorFunction;
(...args: string[]): GeneratorFunction<T>;
/**
* The length of the arguments.
*/
Expand All @@ -67,5 +67,5 @@ interface GeneratorFunctionConstructor {
/**
* A reference to the prototype.
*/
readonly prototype: GeneratorFunction;
readonly prototype: GeneratorFunction<T>;
}
4 changes: 2 additions & 2 deletions lib/lib.es2015.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ interface Function {
[Symbol.hasInstance](value: any): boolean;
}

interface GeneratorFunction {
interface GeneratorFunction<T> {
readonly [Symbol.toStringTag]: string;
}

Expand Down Expand Up @@ -315,4 +315,4 @@ interface SetConstructor {
}
interface ArrayBufferConstructor {
readonly [Symbol.species]: ArrayBufferConstructor;
}
}
18 changes: 9 additions & 9 deletions src/lib/es2015.generator.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
interface Generator extends Iterator<any> { }
interface Generator<T> extends IterableIterator<T> { }

interface GeneratorFunction {
interface GeneratorFunction<T> {
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
new (...args: any[]): Generator;
new (...args: any[]): Generator<T>;
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
(...args: any[]): Generator;
(...args: any[]): Generator<T>;
/**
* The length of the arguments.
*/
Expand All @@ -22,20 +22,20 @@ interface GeneratorFunction {
/**
* A reference to the prototype.
*/
readonly prototype: Generator;
readonly prototype: Generator<T>;
}

interface GeneratorFunctionConstructor {
interface GeneratorFunctionConstructor<T> {
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
new (...args: string[]): GeneratorFunction;
new (...args: string[]): GeneratorFunction<T>;
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
(...args: string[]): GeneratorFunction;
(...args: string[]): GeneratorFunction<T>;
/**
* The length of the arguments.
*/
Expand All @@ -47,5 +47,5 @@ interface GeneratorFunctionConstructor {
/**
* A reference to the prototype.
*/
readonly prototype: GeneratorFunction;
readonly prototype: GeneratorFunction<T>;
}
4 changes: 2 additions & 2 deletions src/lib/es2015.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ interface Function {
[Symbol.hasInstance](value: any): boolean;
}

interface GeneratorFunction {
interface GeneratorFunction<T> {
readonly [Symbol.toStringTag]: string;
}

Expand Down Expand Up @@ -295,4 +295,4 @@ interface SetConstructor {
}
interface ArrayBufferConstructor {
readonly [Symbol.species]: ArrayBufferConstructor;
}
}