Spurious missing `Symbol.iterator` on `never` when `yield*`ing generic call within a generic call
🔎 Search Terms
iteration yield iterator symbol generic call inference
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250228#code/CYUwxgNghgTiAEYD2A7AzgF3gSxSkMAXPAN4BQ88APAIIB8AFAG5QQCuIxNAlMeZZQa94NANwUBAbQDKATwC2AIyQQAdNgwEoGJDAC6QvhIHx8ADwwNV12AHM0xAEogowVBFk0YMKLKpQUWTphAElNHx0YZzQ2CAx-QIAaETpxEwBfNPhMshyyUEhYBAAzNhQwDGxUeCQ2cNpGZWBZYmZWDi5ueABeOngAcRB8CN0E2WSA8fhJ4OImJGxgcTJa8IZS8srUACpqABVGFnZOeD2u-kRUTHg4GLie+FlsEAhgXdxhtuPuUXgAej+8AIMF0AH5cj8yCs6gR1mUKlUULsqAcvh1TucJMh0FgzA8PrCjhxIZRsddbrEsN1Hs9XrszL8ATUANYQ0RAA
💻 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