Closed
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: