microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
98.27k stars 12.21k forks source link

`--isolatedDeclarations` allows generator functions #58334

Open lucacasonato opened 2 weeks ago

lucacasonato commented 2 weeks ago

🔎 Search Terms

🕗 Version & Regression Information

5.5.0-dev.20240426

⏯ Playground Link

https://www.typescriptlang.org/play/?isolatedDeclarations=true&ts=5.5.0-dev.20240426#code/KYDwDg9gTgLgBAMwK4DsDGMCWEUCo4CGAzgCYAUAlHAN4BQcDcAnpsADYlwBMA3PYy3acAzH0ZwowGEigo4ARloBfIA

💻 Code

export function* asd() {
    yield 2;
    yield 3;
    return 1
}

🙁 Actual behavior

This is allowed, the following code is emitted even though it requires inference:

export declare function asd(): Generator<2 | 3, number, unknown>;

🙂 Expected behavior

This is disallowed (probably all generator functions)

Additional information about the issue

cc @dragomirtitian

dragomirtitian commented 2 weeks ago

Thank you for reporting this. I do have a fix for it in a pr that's coming on Monday.