microsoft / microsoft/TypeScript
Tail-Recursion Elimination on Conditional Types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
recursion,instantiation,Tail-Recursion
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
type A = { a: string, b: number }
type B = { a: number, b: string }
type UnionTheTypeOfTheSameKey<R, H> = Omit<R, keyof H> & { [k in keyof H]: k extends keyof R ? R[k] | H[k] : H[k] }
type compute<T> = { [k in keyof T]: T[k] }
type foo<T extends object[], result = {}> = T extends [infer head extends object, ...infer rest extends object[]]
? foo<rest, UnionTheTypeOfTheSameKey<result, head>> : result
// expect ok type test = {a:string|number,b:string|number}
type test = compute<foo<[A, B,]>>
// When the foo length is greater than 33 The result is wrong. type test1 = {a:any,b:any}
type test1 = compute<foo<[A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B]>>
🙁 Actual behavior
// When the foo length is greater than 33 The expected is wrong. type test1 = {a:any,b:any}
type test1 = compute<foo<[A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B]>>
🙂 Expected behavior
// When the foo length is Less than 999 expected test1 = {a:string|number,b:string|number}
type test1 = compute<foo<[A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B]>>
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 riproducendo l’esempio di tipo condizionale ricorsivo nel TypeScript Playground collegato usando la versione indicata, quindi confronta il risultato con il tipo previsto e con le versioni più recenti. Il lavoro è completato quando l’esempio produce {a: string|number, b: string|number} per input più brevi di 999 elementi invece di espandersi a any.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100