microsoft / microsoft/TypeScript
Inferred Promise type breaks ordering of completions
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die verlinkte TypeScript Playground-Reproduktion auszuführen, und vergleiche die Vervollständigungen für good mit denen für bad([]). Verfolge das Vervollständigungsverhalten für den Promise-Subtyp und die generische Inferenz; abgeschlossen ist die Aufgabe, wenn foo und die Promise-Methoden in beiden Fällen vor den aus dem enthaltenen Wert hinzugefügten Eigenschaften erscheinen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100