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

Not sure what happened between 10.1 and 10.6, but the issue no longer appears (code unchanged).

Reading those GitHub links, may be related to some “type” changes they did.

Marking the issue as solved.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.