microsoft / microsoft/TypeScript
Should disallow using the result of calling a void-returning function
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 4.1.0-dev.20201008
Search Terms: disallow function call void return usage warn error
Code
function doesntReturn() {
// no return statement
}
const foo: string = doesntReturn() + 'foo'; // should be an error
Expected behavior:
The expression doesntReturn() + 'foo' should be an error because it uses the value of a void-returning function call. As far as I can tell, there is literally no good reason to use the return value of a function with no return statements like this.
This is similar to the current behavior of disallowing void-returning expressions inside control flow (issue #26262). It is also similar to the reasoning behind the warning that occurs when using a function value (instead of calling it) in an if condition.
Actual behavior:
No error message is given.
Playground Link: here
Related Issues: #26262
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた Playground の例から始めて、不足している診断を再現し、その後、同様の control-flow の動作について関連する issue #26262 を読んでください。void を返す関数呼び出しの結果を使用する式がエラーを報告し、既存の例が引き続き期待どおりに動作すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100