You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @islazh, after having a look at the docs I don't think Express middleware handlers may be async. Having a look at express types:
exportinterfaceRequestHandler<P=ParamsDictionary,ResBody=any,ReqBody=any,ReqQuery=ParsedQs,LocalsObjextendsRecord<string,any>=Record<string,any>,>{// tslint:disable-next-line callable-types (This is extended from and can't extend from a type alias in ts<2.2)(req: Request<P,ResBody,ReqBody,ReqQuery,LocalsObj>,res: Response<ResBody,LocalsObj>,next: NextFunction,): void;}
Closing the issue now. Feel free to provide a code example of an asyncronous middleware working on express and I'll reopen the issue.
EDIT: My bad, After having a look at the right types:
exportinterfaceRequestHandler<P=ParamsDictionary,ResBody=any,ReqBody=any,ReqQuery=ParsedQs,LocalsObjextendsRecord<string,any>=Record<string,any>,>{// tslint:disable-next-line callable-types (This is extended from and can't extend from a type alias in ts<2.2)(req: Request<P,ResBody,ReqBody,ReqQuery,LocalsObj>,res: Response<ResBody,LocalsObj>,next: NextFunction,): void|Promise<void>;}
It seems it's perfectly fine to provide an async handler
Is there an existing issue for this?
Current behavior
When creating a middleware with a handler, the handler's type is
Express middleware handlers may be async, so the return type should be
void | Promise<void>
Steps to reproduce
Create an async middleware handler with no-misused-promises turned on in ESLint config
Expected behavior
No ESLint errors
Possible solution
ESLint warning:
Package version
6.0.1
Node.js version
No response
In which operating systems have you tested?
Stack trace
No response
Other
No response
The text was updated successfully, but these errors were encountered: