microsoft / microsoft/TypeScript
Inferred Promise type breaks ordering of completions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
promise, generic, completion, inference
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about promise/completions (found nothing)
⏯ Playground Link
💻 Code
interface Foo<T> extends Promise<T> {
// This should show up first along with catch, then, finally, etc.
foo(): null;
}
let good: Foo<[]>;
async () => {
// In VS Code, try typing:
//
// good.
}
function bad<T>(x: T): Foo<T> {
return null as any;
}
async () => {
// In VS Code, try typing:
//
// bad([]).
}
🙁 Actual behavior
If a generic is used to infer the type contained in the Promise, then the completions ordering is lost.
This is the correct ordering, foo shows up towards the top:
But if the function returning the Promise subclass is used, the ordering is lost:
🙂 Expected behavior
The methods declared on the Promise and its subclasses / subinterfaces should show up before the "after adding await" properties of whatever is contained in the Promise.
Additional information about the issue
I'd be willing to work on fixing this with some guidance, if it's feasible.
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 eseguendo la riproduzione collegata di TypeScript Playground e confronta i completamenti per good con quelli per bad([]). Traccia il comportamento del completamento per il sottotipo Promise e l’inferenza generica; il lavoro è concluso quando foo e i metodi di Promise compaiono prima delle proprietà aggiunte dal valore contenuto in entrambi i casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100