microsoft / microsoft/TypeScript
More strong Promise<T> in lib.es6.d.ts
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
I think it would be good to be able to define the type of error in Promise type. I suggest promise type to be something like this:
interface Promise<T,U> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: U) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: U) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: U) => T | PromiseLike<T>): Promise<T>;
catch(onrejected?: (reason: U) => void): Promise<T>;
[Symbol.toStringTag]: string;
}
Or at least have a Promise<T, U> type which extends Promise<T>.
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
Beginnen Sie mit den Promise-Deklarationen in lib.es6.d.ts und vergleichen Sie sie mit der im Issue vorgeschlagenen Promise<T,U>-Form mit zwei Parametern. Überprüfen Sie, wie sich der Vorschlag auf then und catch auswirkt, einschließlich der Kompatibilität mit der bestehenden Verwendung von Promise. Als abgeschlossen gilt die Aufgabe, wenn das beabsichtigte Design für typisierte Ablehnungen abgestimmt ist und sich in den relevanten Deklarationen und der Validierungsabdeckung widerspiegelt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100