microsoft / microsoft/TypeScript

The Promise constructor cannot handle void returns on resolve

Open
#45,162 3 comments 0 reactions 1 assignee View on GitHub

@rbuckton is already working on this.

Since Jul 23, 2021.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.