Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add types for iterator helpers proposal #58222

Merged
merged 11 commits into from
Jul 19, 2024
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const libEntries: [string, string][] = [
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.regexp", "lib.esnext.regexp.d.ts"],
["esnext.string", "lib.esnext.string.d.ts"],
["esnext.iterator", "lib.esnext.iterator.d.ts"],
["decorators", "lib.decorators.d.ts"],
["decorators.legacy", "lib.decorators.legacy.d.ts"],
];
Expand Down
46 changes: 23 additions & 23 deletions src/lib/dom.iterable.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/// <reference lib="dom" />

interface DOMTokenList {
[Symbol.iterator](): IterableIterator<string, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
}

interface Headers {
[Symbol.iterator](): IterableIterator<[string, string], BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
/**
* Returns an iterator allowing to go through all key/value pairs contained in this object.
*/
entries(): IterableIterator<[string, string], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
/**
* Returns an iterator allowing to go through all keys f the key/value pairs contained in this object.
*/
keys(): IterableIterator<string, BuiltinIteratorReturn>;
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
/**
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
*/
values(): IterableIterator<string, BuiltinIteratorReturn>;
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
}

interface NodeList {
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[number, Node], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[number, Node], BuiltinIteratorReturn>;
/**
* Performs the specified action for each node in an list.
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
Expand All @@ -34,21 +34,21 @@ interface NodeList {
/**
* Returns an list of keys in the list
*/
keys(): IterableIterator<number, BuiltinIteratorReturn>;
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;

/**
* Returns an list of values in the list
*/
values(): IterableIterator<Node, BuiltinIteratorReturn>;
values(): BuiltinIterator<Node, BuiltinIteratorReturn>;

[Symbol.iterator](): IterableIterator<Node, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<Node, BuiltinIteratorReturn>;
}

interface NodeListOf<TNode extends Node> {
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[number, TNode], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[number, TNode], BuiltinIteratorReturn>;

/**
* Performs the specified action for each node in an list.
Expand All @@ -59,55 +59,55 @@ interface NodeListOf<TNode extends Node> {
/**
* Returns an list of keys in the list
*/
keys(): IterableIterator<number, BuiltinIteratorReturn>;
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the list
*/
values(): IterableIterator<TNode, BuiltinIteratorReturn>;
values(): BuiltinIterator<TNode, BuiltinIteratorReturn>;

[Symbol.iterator](): IterableIterator<TNode, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<TNode, BuiltinIteratorReturn>;
}

interface HTMLCollectionBase {
[Symbol.iterator](): IterableIterator<Element, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<Element, BuiltinIteratorReturn>;
}

interface HTMLCollectionOf<T extends Element> {
[Symbol.iterator](): IterableIterator<T, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
}

interface FormData {
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[string, string | File], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[string, string | File], BuiltinIteratorReturn>;
/**
* Returns a list of keys in the list
*/
keys(): IterableIterator<string, BuiltinIteratorReturn>;
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
/**
* Returns a list of values in the list
*/
values(): IterableIterator<string | File, BuiltinIteratorReturn>;
values(): BuiltinIterator<string | File, BuiltinIteratorReturn>;

[Symbol.iterator](): IterableIterator<string | File, BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<string | File, BuiltinIteratorReturn>;
}

interface URLSearchParams {
/**
* Returns an array of key, value pairs for every entry in the search params
*/
entries(): IterableIterator<[string, string], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
/**
* Returns a list of keys in the search params
*/
keys(): IterableIterator<string, BuiltinIteratorReturn>;
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
/**
* Returns a list of values in the search params
*/
values(): IterableIterator<string, BuiltinIteratorReturn>;
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
/**
* iterate over key/value pairs
*/
[Symbol.iterator](): IterableIterator<[string, string], BuiltinIteratorReturn>;
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
}
2 changes: 1 addition & 1 deletion src/lib/es2015.generator.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="es2015.iterable" />

interface Generator<T = unknown, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
interface Generator<T = unknown, TReturn = any, TNext = any> extends BuiltinIterator<T, TReturn, TNext> {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
return(value: TReturn): IteratorResult<T, TReturn>;
Expand Down
Loading