Skip to content

Promise<void> should work like void #46461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DetachHead opened this issue Oct 21, 2021 · 1 comment
Closed

Promise<void> should work like void #46461

DetachHead opened this issue Oct 21, 2021 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@DetachHead
Copy link
Contributor

Bug Report

πŸ”Ž Search Terms

promise void

πŸ•— Version & Regression Information

4.5.0-dev.20211021

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare const foo: (fn: () => Promise<void>) => void

//error: Type 'Promise<number>' is not assignable to type 'Promise<void>'.
foo(async () => 1)

πŸ™ Actual behavior

error: Type 'Promise<number>' is not assignable to type 'Promise<void>'.

πŸ™‚ Expected behavior

a function that returns a Promise for a non-null value should be assignable to a function that returns Promise<void> because that's the purpose of void. see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void

@MartinJohns
Copy link
Contributor

Duplicate of #44201 / #12871. Used search terms: promise void in:title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants