microsoft / microsoft/TypeScript
The Promise constructor cannot handle void returns on resolve
Open
@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:

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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.