Skip to content
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

Spurious missing Symbol.iterator on never when yield*ing generic call within a generic call #61318

Open
Andarist opened this issue Feb 28, 2025 · 0 comments Β· May be fixed by #61317
Open

Spurious missing Symbol.iterator on never when yield*ing generic call within a generic call #61318

Andarist opened this issue Feb 28, 2025 · 0 comments Β· May be fixed by #61317

Comments

@Andarist
Copy link
Contributor

πŸ”Ž 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant