microsoft / microsoft/TypeScript

Parameters and readonly tuples

オープン
#45,276 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: check: Type Inference
主要言語
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].

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。