microsoft / microsoft/TypeScript
Can extends [any, any] but not generic which is exactly [any, any] (woks till 5.3.3 breaks from 5.4.5)
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
generic, tuple extends
🕗 Version & Regression Information
This code works in the playground with typescript version 5.3.3 but breaks since version 5.4.5 (version between are not available in the playground)
⏯ Playground Link
💻 Code
type Data = [a: 1, b: 2, ...c: 3[]]
type TestType1<T extends any[]> =
T extends [...infer R extends [any, any], ...any[]] ? R : never
type test1 = TestType1<Data>
// ^?
type TestType2<T extends any[], Mask extends any[] = [any, any]> =
T extends [...infer R extends Mask, ...any[]] ? R : never
type test2 = TestType2<Data>
// ^?
🙁 Actual behavior
When passing the Mask as a generic and trying to extends the tuple with it to extract the relevant part, the resulting tuple is well formed, but item types are replaced with any
🙂 Expected behavior
Expect that constraint on infer to works wether as an explicit form or a generic holding a type with the exact same form, which used to be the case priori to typescript 5.4 bu breaks since
Additional information about the issue
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript playground から始め、5.3.3 と 5.6.3 における条件付きタプル推論の挙動を比較し、ジェネリックな Mask のケースと明示的な [any, any] 制約に焦点を当てます。完了条件は、報告されている挙動を後退させることなく、TestType2 が TestType1 と同じ方法でタプル要素の型を保持することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100