Skip to content
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

awaited operator is not introduced to async generators #37528

Closed
falsandtru opened this issue Mar 23, 2020 · 0 comments · Fixed by #37610
Closed

awaited operator is not introduced to async generators #37528

falsandtru opened this issue Mar 23, 2020 · 0 comments · Fixed by #37610

Comments

@falsandtru
Copy link
Contributor

@rbuckton Can you?

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

Expected behavior:

interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
    // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
    next(...args: [] | [TNext]): Promise<IteratorResult<awaited T, awaited TReturn>>;
    return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<awaited T, awaited TReturn>>;
    throw(e: any): Promise<IteratorResult<awaited T, awaited TReturn>>;
    [Symbol.asyncIterator](): AsyncGenerator<awaited T, awaited TReturn, TNext>;
}
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<awaited T, awaited TReturn>>;
    return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<awaited T, awaited TReturn>>;
    throw?(e?: any): Promise<IteratorResult<awaited T, awaited TReturn>>;
}

Actual behavior:

interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
    // 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>>;
    [Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
}
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>>;
}

Playground Link:

Related Issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant