microsoft / microsoft/TypeScript
Improve error message for @ts-expect-error directive
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
I've just been looking for a way to "unit test" some quite complicated generic type signatures, and have just come across the @ts-expect-error and @ts-expect-no-error directives, which I think are fantastic for this kind of use case.
However, if I do something like this:
let myVar = 'bob';
// @ts-expect-error
myVar = 'fred';
The actual error I get is "Unused '@ts-expect-error' directive".
This makes it look as though the directive has been used incorrectly (which obviously it has in this very simple example), but this seems like it will be confusing for anyone subsequently involved in maintaining my code - because it looks as though all they need to do is remove the directive in order to fix the problem, whereas generally speaking, I will have put the directive there for a good reason, and if it's "unused" it means that somebody has broken the type signature logic.
Please could this error message be changed to shift the emphasis more onto the code being wrong, rather than the directive needing to be removed?
E.g.: "'@ts-expect-error' directive - this code should have failed type-checking, but didn't"
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、"Unused '@ts-expect-error' directive" と報告する診断を見つけ、関連する compiler tests があれば確認します。注釈付きのコードが予期せず型チェックを通過したことを強調するように文言を更新し、その後、例が改訂された診断を出力することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100