Consider the code snippet below:
function* gen() {
let v = yield Promise.resolve(0);
return v;
}
The variable v
is automatically assigned the type any
. Is there a method to indicate a specific type (such as number
) based on the context of the code?
Although using async
/await
would solve this issue in this particular case, I am interested in a more general solution that doesn't involve promises.