Express router: Promise returned in function argument where a void return was expected

Environment:

  • Community Edition, Version 10.1 (build 73491)
  • Local Sonar on pod with Podman and WSL

Description:
Sonar is wrongly flagging some code. As per ExpressJS 5 - Promise returned in function argument where a void return was expected. · Issue #4892 · expressjs/express · GitHub, this is valid code (to pass an async function to the Router).

Also: [@types/express-serve-static-core] async handlers typings · Issue #50871 · DefinitelyTyped/DefinitelyTyped · GitHub

“In express 4, async functions are supported”

image

Hello @gian1200,

this issue comes from the typings you are using, as read in the links you posted. Did you try the type wrapper as proposed by this user?

Cheers,
Victor