microsoft / microsoft/TypeScript

The Promise constructor cannot handle void returns on resolve

Aperta
#45,162 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@rbuckton ci sta già lavorando.

Dal 23/7/2021.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.