microsoft / microsoft/TypeScript

Strange 2488 error involving overload resolution and this parameter type

Aperta
#60,374 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@rbuckton ci sta già lavorando.

Dal 31/10/2024.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

yield ts2488 never iterator

🕗 Version & Regression Information
  • This changed between versions 3.5.1 and 3.6.2

every-ts bisect gives: e8bf9584aa74aabfecb51a02edb13e3657508274 is the first bad commit

⏯ Playground Link

https://www.typescriptlang.org/play/?module=1&ts=5.7.0-dev.20241030#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQB4AVAPgAoA3KCZEALnnIEp4BeU+Y5xgbyZ5d4AXwDcAKFCRYCFOmx4CJCtVoMuggJIYQMKACMIIQmgDWqHAHdUpCeJAAPAA44YGeNIDOn+AEF4vOLwwfBQ7ATkcpi4qABUTBgAFliejL6sgSFZ8ACeWCAQwPGIqOQAjMwSWcKV4kEh+uElkWjRePHkSSlpGfXZHnie7joAtk5NpRVV-bn5hfGjTtPBNRLC4kA

💻 Code
declare function fn<T>(value: () => T): { (): T };
declare function fn<T>(value: T): Iterable<unknown>;

export class A {
    a = fn(function* (this: A) {
        yield* fn(1); // error
    });

    b = fn(function* (this: A) {
        const temp = fn(1); // ok
        yield* temp;
    });
}

🙁 Actual behavior
src/error.ts:6:16 - error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.

6         yield* fn(1);
                 ~~~~~
🙂 Expected behavior

No error, as in A.b

Additional information about the issue

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.