• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// <reference lib="es2015.symbol" />
2/// <reference lib="es2015.iterable" />
3
4interface SymbolConstructor {
5    /**
6     * A method that returns the default async iterator for an object. Called by the semantics of
7     * the for-await-of statement.
8     */
9    readonly asyncIterator: symbol;
10}
11
12interface AsyncIterator<T, TReturn = any, TNext = undefined> {
13    // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
14    next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
15    return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
16    throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
17}
18
19interface AsyncIterable<T> {
20    [Symbol.asyncIterator](): AsyncIterator<T>;
21}
22
23interface AsyncIterableIterator<T> extends AsyncIterator<T> {
24    [Symbol.asyncIterator](): AsyncIterableIterator<T>;
25}