Open Binero opened 3 years ago
This issue is made visible with the following eslint rule enabled: https://github.com/typescript-eslint/typescript-eslint/blob/v4.2.0/packages/eslint-plugin/docs/rules/no-misused-promises.md
The following code lights up as a warning due to the rule:
const getList = asyncHandler(
async (req: Request, res: Response): Promise<void> => {
// async code
},
);
I have the same issue. It seems that there is a PR for that: https://github.com/Abazhenov/express-async-handler/pull/40 Can you merge it please?
The Typescript function is defined to take an
express.RequestHandler
which returnsvoid
. This ironically means it cannot take an async function as an argument, as this would returnPromise<void>
.https://github.com/Abazhenov/express-async-handler/blob/master/index.d.ts#L3