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)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il TypeScript playground collegato e confronta il comportamento dell’inferenza condizionale delle tuple in 5.3.3 e 5.6.3, concentrandoti sul caso generico Mask rispetto al vincolo esplicito [any, any]. Il lavoro è completato quando TestType2 preserva i tipi degli elementi della tupla nello stesso modo di TestType1, senza regressioni nel comportamento segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100