-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Split Iterator into Iterator and IterableIterator in es6.d.ts #2083
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f86f05d
Split Iterator into Iterator and IterableIterator in es6.d.ts
JsonFreeman e7435b1
Merge branch 'master' into iterators
JsonFreeman 395a1e6
Make IterableIterator deeply iterable
JsonFreeman a66cdf8
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman 7711a45
[Symbol.iterator] of a Generator is a Generator
JsonFreeman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,22 +230,22 @@ interface ArrayLike<T> { | |
|
||
interface Array<T> { | ||
/** Iterator */ | ||
[Symbol.iterator] (): Iterator<T>; | ||
[Symbol.iterator](): IterableIterator<T>; | ||
|
||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, T]>; | ||
entries(): IterableIterator<[number, T]>; | ||
|
||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<T>; | ||
values(): IterableIterator<T>; | ||
|
||
/** | ||
* Returns the value of the first element in the array where predicate is true, and undefined | ||
|
@@ -329,7 +329,7 @@ interface ArrayConstructor { | |
|
||
interface String { | ||
/** Iterator */ | ||
[Symbol.iterator] (): Iterator<string>; | ||
[Symbol.iterator](): IterableIterator<string>; | ||
|
||
/** | ||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point | ||
|
@@ -447,14 +447,17 @@ interface IteratorResult<T> { | |
} | ||
|
||
interface Iterator<T> { | ||
[Symbol.iterator](): Iterator<T>; | ||
next(): IteratorResult<T>; | ||
return?(value?: any): IteratorResult<T>; | ||
throw?(e?: any): IteratorResult<T>; | ||
} | ||
|
||
interface Iterable<T> { | ||
[Symbol.iterator](): Iterator<T>; | ||
} | ||
|
||
interface IterableIterator<T> extends Iterable<T>, Iterator<T> { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to fix this because it's not deeply iterable, so it won't work if you do: var iter: IterableIterator<any>;
iter[Symbol.iterator]()[Symbol.iterator](); The type IterableIterator needs to be recursive for this to work. |
||
|
||
interface GeneratorFunction extends Function { | ||
|
||
} | ||
|
@@ -470,7 +473,7 @@ interface GeneratorFunctionConstructor { | |
} | ||
declare var GeneratorFunction: GeneratorFunctionConstructor; | ||
|
||
interface Generator<T> extends Iterator<T> { | ||
interface Generator<T> extends IterableIterator<T> { | ||
next(value?: any): IteratorResult<T>; | ||
throw (exception: any): IteratorResult<T>; | ||
return (value: T): IteratorResult<T>; | ||
|
@@ -641,15 +644,15 @@ interface RegExp { | |
interface Map<K, V> { | ||
clear(): void; | ||
delete(key: K): boolean; | ||
entries(): Iterator<[K, V]>; | ||
entries(): IterableIterator<[K, V]>; | ||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void; | ||
get(key: K): V; | ||
has(key: K): boolean; | ||
keys(): Iterator<K>; | ||
keys(): IterableIterator<K>; | ||
set(key: K, value?: V): Map<K, V>; | ||
size: number; | ||
values(): Iterator<V>; | ||
[Symbol.iterator]():Iterator<[K,V]>; | ||
values(): IterableIterator<V>; | ||
[Symbol.iterator]():IterableIterator<[K,V]>; | ||
[Symbol.toStringTag]: string; | ||
} | ||
|
||
|
@@ -680,13 +683,13 @@ interface Set<T> { | |
add(value: T): Set<T>; | ||
clear(): void; | ||
delete(value: T): boolean; | ||
entries(): Iterator<[T, T]>; | ||
entries(): IterableIterator<[T, T]>; | ||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void; | ||
has(value: T): boolean; | ||
keys(): Iterator<T>; | ||
keys(): IterableIterator<T>; | ||
size: number; | ||
values(): Iterator<T>; | ||
[Symbol.iterator]():Iterator<T>; | ||
values(): IterableIterator<T>; | ||
[Symbol.iterator]():IterableIterator<T>; | ||
[Symbol.toStringTag]: string; | ||
} | ||
|
||
|
@@ -917,7 +920,7 @@ interface Int8Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -997,7 +1000,7 @@ interface Int8Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -1134,10 +1137,10 @@ interface Int8Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Int8ArrayConstructor { | ||
|
@@ -1207,7 +1210,7 @@ interface Uint8Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -1287,7 +1290,7 @@ interface Uint8Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -1424,10 +1427,10 @@ interface Uint8Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Uint8ArrayConstructor { | ||
|
@@ -1497,7 +1500,7 @@ interface Uint8ClampedArray { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -1577,7 +1580,7 @@ interface Uint8ClampedArray { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -1714,10 +1717,10 @@ interface Uint8ClampedArray { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Uint8ClampedArrayConstructor { | ||
|
@@ -1787,7 +1790,7 @@ interface Int16Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -1867,7 +1870,7 @@ interface Int16Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -2004,10 +2007,10 @@ interface Int16Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Int16ArrayConstructor { | ||
|
@@ -2077,7 +2080,7 @@ interface Uint16Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -2157,7 +2160,7 @@ interface Uint16Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -2294,10 +2297,10 @@ interface Uint16Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Uint16ArrayConstructor { | ||
|
@@ -2367,7 +2370,7 @@ interface Int32Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -2447,7 +2450,7 @@ interface Int32Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -2584,10 +2587,10 @@ interface Int32Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Int32ArrayConstructor { | ||
|
@@ -2657,7 +2660,7 @@ interface Uint32Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -2737,7 +2740,7 @@ interface Uint32Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -2874,10 +2877,10 @@ interface Uint32Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Uint32ArrayConstructor { | ||
|
@@ -2947,7 +2950,7 @@ interface Float32Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -3027,7 +3030,7 @@ interface Float32Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -3164,10 +3167,10 @@ interface Float32Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Float32ArrayConstructor { | ||
|
@@ -3237,7 +3240,7 @@ interface Float64Array { | |
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): Iterator<[number, number]>; | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Determines whether all the members of an array satisfy the specified test. | ||
|
@@ -3317,7 +3320,7 @@ interface Float64Array { | |
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): Iterator<number>; | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns the index of the last occurrence of a value in an array. | ||
|
@@ -3454,10 +3457,10 @@ interface Float64Array { | |
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): Iterator<number>; | ||
values(): IterableIterator<number>; | ||
|
||
[index: number]: number; | ||
[Symbol.iterator] (): Iterator<number>; | ||
[Symbol.iterator](): IterableIterator<number>; | ||
} | ||
|
||
interface Float64ArrayConstructor { | ||
|
@@ -3516,7 +3519,7 @@ declare var Reflect: { | |
construct(target: Function, argumentsList: ArrayLike<any>): any; | ||
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; | ||
deleteProperty(target: any, propertyKey: PropertyKey): boolean; | ||
enumerate(target: any): Iterator<any>; | ||
enumerate(target: any): IterableIterator<any>; | ||
get(target: any, propertyKey: PropertyKey, receiver?: any): any; | ||
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; | ||
getPrototypeOf(target: any): any; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. It returns something htat is both an iterator, and something you can get an iterator off of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all the built-in ES6 iterators are like that.