microsoft / microsoft/TypeScript
No warning when using unary +/- operators on functions and objects?
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 2.6.1
Code
let func = () => "func";
+func; // no error
-func; // no error
let obj = { foo: "bar" };
+obj; // no error
-obj; // no error
Expected behavior:
Unary + or - is only applicable to a number or maybe a string. I would expect the lines listed as // no error to be errors.
Actual behavior:
Unary + and - never generates a warning no matter what crazy stuff I try to apply it to.
I was made aware of this behavior by a recent Stack Overflow question. I see from #7019 that unary + and - on strings is supported, and I guess I can understand that as a way to parse a string into a number (for +, anyway. Is - really used like this in practice?). But functions? objects? Seems more likely to be an error than intentional to me. Thoughts?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
TypeScript 2.6.1 の例を再現し、関数、オブジェクト、文字列に対する単項 + と - の診断を比較します。既存の単項演算子の型チェック動作を確認します。完了条件は、意図した無効なオペランドでエラーが発生し、サポートされている文字列の動作が意図的なものとして維持され、テストでカバーされていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100