microsoft / microsoft/TypeScript
Infer type isn't contextual typed by type bounds
Aperta
Nessuno ha ancora preso questa issue.
Bug
Domain: Conditional Types
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Bug Report
Infer type isn't contextual typed by type bounds
type Foo<T> = T extends string ? Record<T, number> : never;
type Foo2<T extends {a:string}>= T extends {a: infer A} ? Record<A, number>:never; //error here, A should extends string already, but seems not
🔎 Search Terms
generic infer bounds
🕗 Version & Regression Information
4.2.3
⏯ Playground Link
💻 Code
type Foo<T> = T extends string ? Record<T, number> : never;
type Foo2<T extends {a:string}>= T extends {a: infer A} ? Record<A, number>:never; //error here, A should extends string already, but seems not
🙁 Actual behavior
throw error
🙂 Expected behavior
not throw error
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 l’esempio ridotto Foo2 per riprodurre l’errore. L’issue non indica alcun file sorgente né alcun test; traccia come il compilatore gestisce i vincoli di tipo inferiti, quindi verifica che l’esempio accetti Record<A, number> come previsto e aggiungi la copertura di regressione.
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