Skip to content

A function with a return type of void can't be awaited without a warning #58459

@mybearworld

Description

@mybearworld

🔎 Search Terms

await promise void "'await' has no effect on the type of this expression" function return type parameter

🕗 Version & Regression Information

  • This changed between versions 3.6.3 and 3.7.5

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.5.0-dev.20240507#code/MYewdgzgLgBAJiAyiAtgUygCwJZgOYwC8MAhhAJ5jAwAUwJANgwEYnADWAXLQJREB8MAG4hscPoUEBvAFAxSAdxLZY9Jqw40eMgL4yZCZOiy48NMpWpaBMWfID09mADpXunkA

💻 Code

const doSomething = async (callback: () => void) => {
  await callback()
}

doSomething(async () => {
  // ...
})

🙁 Actual behavior

There is a warning at the "await" saying

'await' has no effect on the type of this expression.(80007)

But the return type might be a promise.

🙂 Expected behavior

No warning

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions