microsoft / microsoft/TypeScript

The Promise constructor cannot handle void returns on resolve

Offen
#45,162 3 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@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:
image

Workaround

The current workaround is to return undefined:
image

But undefined is not the same as void: https://www.typescriptlang.org/docs/handbook/2/functions.html#void

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.