microsoft / microsoft/TypeScript
Improve diagnostic when string from property is not assignable to string literal.
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.1.0-dev.20180810
Code
interface IceCreamOptions {
readonly cherry: "yes" | "no"
}
declare function iceCream(options: IceCreamOptions): void;
const options = { cherry: "yes" };
iceCream(options);
Expected behavior:
Error message recommending to add a type annotation to options. This should be detectable because the source of the failing property is a PropertyAssignment in an object literal being assigned to a variable. (If there is no variable assignment, we could still recommend using ``"yes" as "yes"although that isn't as pretty.)
Could also come with a codefix. Note that in JS the fix is slightly different: put/** @type {IceCreamOptions} /` before the `const` or use `/* @type {"yes"} */ ("yes")`.
Actual behavior:
Error messages says Type 'string' is not assignable to type '"yes" | "no"'. with no information on how to fix it.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された TypeScript 3.1 の例を再現し、オブジェクトリテラルのプロパティ代入に対する assignability 診断を追跡します。既存のメッセージがどこで生成されるか、また TypeScript がソースプロパティをどのように識別するかを特定します。診断が適切なアノテーションを推奨し、その範囲が受け入れられる場合にのみ codefix を追加できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100