microsoft / microsoft/TypeScript
The Promise constructor cannot handle void returns on resolve
Offen
@rbuckton arbeitet bereits daran.
Seit 23.7.2021.
Needs Investigation
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Configuration Check
My compilation target is es5 and my lib is dom, es5, es2015.promise and es2015.iterable.
Missing / Incorrect Definition
The value for the resolve callback in the Promise constructor is required:
new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
Sample Code
Using void as the generic (return) type for a Promise results in an error:

Workaround
The current workaround is to return undefined:

But undefined is not the same as void: https://www.typescriptlang.org/docs/handbook/2/functions.html#void
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.
Bewertung
Dieses Issue wurde noch nicht bewertet.