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
I'm working on migrating a service from express. One of the routes currently has 4 middlewares and the TS compiler is giving me an error: Expected 2-5 arguments, but got 6.
After some digging, I think I found the source of the issue in the type declaration file. It seems odd to me that one could only place up to three middlewares before the handler, and after that would have to switch to a different pattern and use an array for the middlewares, placed after the handler. (Also, side note, the second block seems like a duplicate of the first one?)
interfaceRegisterRoute<PextendsProtocol>{(path: string,handler: RequestHandler<P>,middlewares?: RequestHandler<P>[]): Service<P>// this seems like a duplicate?(path: string,handler: RequestHandler<P>,middlewares?: RequestHandler<P>[]): Service<P>(path: string,middleware1: RequestHandler<P>,handler: RequestHandler<P>,): Service<P>(path: string,middleware1: RequestHandler<P>,middleware2: RequestHandler<P>,handler: RequestHandler<P>,): Service<P>(path: string,middleware1: RequestHandler<P>,middleware2: RequestHandler<P>,middleware3: RequestHandler<P>,handler: RequestHandler<P>,): Service<P>}
Is it not possible to use a rest parameter, since all middlewares and handlers are RequestHandler<P>?
I'm working on migrating a service from express. One of the routes currently has 4 middlewares and the TS compiler is giving me an error:
Expected 2-5 arguments, but got 6
.After some digging, I think I found the source of the issue in the type declaration file. It seems odd to me that one could only place up to three middlewares before the handler, and after that would have to switch to a different pattern and use an array for the middlewares, placed after the handler. (Also, side note, the second block seems like a duplicate of the first one?)
Is it not possible to use a rest parameter, since all middlewares and handlers are
RequestHandler<P>
?The text was updated successfully, but these errors were encountered: