mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
87d10eb055
* Eliminate well-known symbols in the checker: 2021 edition * Actually update the lib text to say unique symbol, too (this is unneeded with compat code in place, but this makes goto-def make more sense) * Add test showing mismatched symbol constructor type interop * Add more test cases for some other related issues this fixes * Revert computed name change * Style comments
25 lines
924 B
TypeScript
25 lines
924 B
TypeScript
/// <reference lib="es2015.symbol" />
|
|
/// <reference lib="es2015.iterable" />
|
|
|
|
interface SymbolConstructor {
|
|
/**
|
|
* A method that returns the default async iterator for an object. Called by the semantics of
|
|
* the for-await-of statement.
|
|
*/
|
|
readonly asyncIterator: unique symbol;
|
|
}
|
|
|
|
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
|
|
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
|
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
|
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
|
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
|
|
}
|
|
|
|
interface AsyncIterable<T> {
|
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
}
|
|
|
|
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
|
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
} |