-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Error with async generators #32247
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: master
Search Terms:
Code
const g: <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U> = async <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>): Promise<U> => {
throw com;
};Expected behavior:
pass
Actual behavior:
index.ts:1:7 - error TS2719: Type '<U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U>' is not assignable to type '<U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U>'. Two different types with this name exist, but they are unrelated.
Type 'Promise<U | PromiseLike<U>>' is not assignable to type 'Promise<U>'.
Type 'U | PromiseLike<U>' is not assignable to type 'U'.
'U | PromiseLike<U>' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'.
Type 'PromiseLike<U>' is not assignable to type 'U'.
'PromiseLike<U>' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'.
1 const g: <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U> = async <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>): Promise<U> => {
~
Playground Link:
Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue