microsoft / microsoft/TypeScript
Dead return statements in a generator should offer a did-you-mean-yield codefix
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.0.0-dev.201xxxxx
Search Terms: yield return generator
Currently it is possible to have the following code:
Code
async function *myGeneratorFunction(): AsyncIterableIterator<number> {
return 1;
return 2;
return 3;
}
Expected behavior:
A generator function that yields numbers 1 - 3
Actual behavior:
No syntax/runtime error but due to a human mistake the generator function is useless.
I copy/pasted an existing generator function, deleted the body with the new implementation and mistakenly used return instead of yield.
It would be nice if TypeScript could warn when it's encountering a return with an actual value inside a generator function.
It makes no sense to return a value.
Could be combined with a codefix in the IDE: Did you mean yield?
Playground Link:
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue の async generator の例を再現し、コンパイラーと language-service におけるジェネレーター内の return 文の扱いを調査します。ジェネレーター内の値を持つ return が意図した警告を生成し、IDE が「Did you mean yield?」という codefix を提示し、例の動作をカバーできれば作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100