Microsoft/TypeScript

`--isolatedDeclarations` allows generator functions

Open

#58,334 建立於 2024年4月26日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: flag: isolatedDeclarationsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 Search Terms

  • generator functions
  • isolated declartions
  • yield

🕗 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

貢獻者指南