-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Missing generator's type parameter in functions and constructors #32248
Comments
This is an issue with contextual typing. The contextual type from the constructor isn't flowing to the async generator. |
Since the constructor has been given all type parameters the type of the parameter gen must be AsyncGenerator<0, 0, 1>. All type parameters are clearly decided. And the return type of yield must be unknown with the current behavior, as is defined by the context type. |
Note that the type declaration for |
Same also with functions. export function f<T = unknown, R = unknown, S = unknown>(gen: () => Generator<R, T, S> | AsyncGenerator<R, T, S>) {
}
f<0, 0, 1>(async function* g() {
const a = yield 0;
return 0;
}); |
@rbuckton Why you still haven't fixed this bug? |
Thanks @rbuckton ! |
@RyanCavanaugh Label this. |
@rbuckton
TypeScript Version: master
Search Terms:
Code
Expected behavior:
Type g is AsyncGenerator<0, 0, 1>.
Type a is 1.
Actual behavior:
Type g is AsyncGenerator<0, 0, unknown>.
Type a is any.
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: