microsoft / microsoft/TypeScript
Tuple should be readonly by default
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Any tuples can mutate, this entails incorrect typing
TypeScript Version: 4.1.0-dev.20200828
Search Terms:
"readonly tuple"
"immutable tuple"
Code
const exampleSort: [number, string] = [2, '1'];
exampleSort.sort();
exampleSort // Type: [number, string], RealType: [string, number]
const exampleSplice: [number, string] = [2, '1'];
exampleSplice.splice(0, 1);
exampleSplice // Type: [number, string], RealType: [string]
Expected behavior:
const exampleSort: [number, string] = [2, '1'];
// Property 'sort' does not exist on type '[number, string]'.(2339)
exampleSort.sort();
const exampleSplice: [number, string] = [2, '1'];
// Property 'splice' does not exist on type '[number, string]'.(2339)
exampleSplice.splice(0, 1);
Actual behavior:
const exampleSort: [number, string] = [2, '1'];
exampleSort.sort();
const exampleSplice: [number, string] = [2, '1'];
exampleSplice.splice(0, 1);
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた TypeScript Playground でタプルの例を再現し、報告された型を sort と splice による実行時の変更と比較します。コンパイラーがタプルと配列の可変性をどのように扱うかを追跡します。これらの操作に対して期待される診断が表示され、タプルの有効な使用を壊さなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100