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)
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
🔎 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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le TypeScript playground lié et comparez le comportement de l’inférence conditionnelle des tuples dans 5.3.3 et 5.6.3, en vous concentrant sur le cas générique Mask par rapport à la contrainte explicite [any, any]. C’est terminé lorsque TestType2 préserve les types des éléments du tuple de la même manière que TestType1, sans régression du comportement signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100