Closed
Description
π Search Terms
iteration yield iterator symbol generic call inference
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
declare const inner: {
<A>(value: A): {
(): A;
[Symbol.iterator](): {
next(...args: ReadonlyArray<any>): IteratorResult<any, A>;
};
};
};
declare function outer<A>(body: (value: A) => Generator<any, any, any>): void;
outer(function* <T>(value: T) {
const result = yield* inner(value); // error?
});
outer(function* <T>(value: T) {
const x = inner(value);
const result = yield* x; // ok
});
π Actual behavior
It errors on the first inner
call with a spurious error
π Expected behavior
it shouldn't error, both calls to inner
are the same here - the second one that happens outside of the yield*
context works just OK
Additional information about the issue
This signature is crafted based on the problem diagnosis. The original issue can be seen in a better example here: TS playground