microsoft / microsoft/TypeScript
Parameters and readonly tuples
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
I've encountered a wrong type inference regarding the Parameters generic when the rest operator and the union of readonly tuples are used together.
🔎 Search Terms
infer, Parameters, readonly.
🕗 Version & Regression Information
I have only tested this on TypeScript 4.3.5.
⏯ Playground Link
Playground link with relevant code
In this example, P1 is correctly inferred, whereas P2 is not.
💻 Code
type F = (...args: readonly [number, string] | readonly [string, number]) => void;
type P = Parameters<F>;
🙁 Actual behavior
The type P is never.
🙂 Expected behavior
One would expect P to be of type readonly [number, string] | readonly [string, number].
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript Playground の例から始め、readonly タプル共用体に対する Parameters の推論を再現してください。コンパイラーによる rest パラメーター、共用体タプル、Parameters の処理を追跡し、その後、P が never ではなく readonly [number, string] | readonly [string, number] として推論されることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100