microsoft / microsoft/TypeScript
Rest element type not recognized for inner array types
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
Hello,
The compiler doesn't recognize an inner array type as an "array type" when inferred in a conditional type.
🔎 Search Terms
I searched for array, rest element, inner array type, multidimensional array type.
Couldn't find anything.
⏯ Playground Link
Playground link with relevant code
💻 Code
The compiler complains with the following code:
type PushToTopArray<T, ArrayOfArray extends any[][]> =
ArrayOfArray extends [infer TopArray, ...infer Rest] ?
[[T, ...TopArray], ...Rest] :
never;
🙁 Actual behavior
with error: A rest element type must be an array type. (2574) on ...TopArray.
🙂 Expected behavior
But since ArrayOfArray extends any[][], the inferred TopArray should be of type any[] and therefore satisfy the rest element type.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の再現例から始め、条件型の推論された TopArray rest 要素でエラーが発生することを確認します。コンパイラの条件型の推論と rest 要素の検証を追跡し、推論された内部配列が受け入れられ、再現例がエラーなしで型チェックされることを示すカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100