microsoft / microsoft/TypeScript
Union in a computed property allows any assignment to property value
オープン
まだ誰も着手していません。
Experimentation Needed
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 4.0.0-dev.20200518
Search Terms: computed property, union
Code
type Key = 'a' | 'b';
const index1: Record<Key, string> = { a: '', b: 0 }; // Errors as expected, ok
const index2: Record<Key, string> = { a: '', b: '' };
const b: Key = 'b';
const index3: Record<Key, string> = { ...index2, [b]: 0 }; // Errors as expected, ok
declare var k: Key;
// No errors, allowing anything to be assigned to string
const index4: Record<Key, string> = { ...index2, [k]: [] };
const index5: Record<Key, string> = { a: '', b: '', [k]: 0 };
Expected behavior:
Expected error for invalid assignments in index4 and index5.
Actual behavior:
No error, allowing anything to be assigned to string
Playground Link: here
Related Issues:
https://github.com/microsoft/TypeScript/issues/36920: perhaps the computed property is deemed an excess property, though I don't think it should be
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている Playground の再現コードを実行し、index4 と index5 の診断を期待されるエラーと比較します。計算プロパティの処理と excess-property checking を調査し、関連する issue #36920 も確認します。完了の条件は、正常な例にリグレッションを発生させずに、無効な代入の両方が拒否されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100