From cd8772a014edba36718853aa867bd87099631035 Mon Sep 17 00:00:00 2001 From: Patrick McLaughlin Date: Tue, 26 Jul 2022 18:27:37 -0400 Subject: [PATCH] fix: add default param to requestHandler impl I also figured out how to actually use a narrow impl type without it complaining. --- packages/express-wrapper/src/request.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/express-wrapper/src/request.ts b/packages/express-wrapper/src/request.ts index e47bdd53..ba2c797d 100644 --- a/packages/express-wrapper/src/request.ts +++ b/packages/express-wrapper/src/request.ts @@ -61,9 +61,12 @@ export function routeHandler }): RouteHandler; export function routeHandler({ - middleware, + middleware = [], handler, -}: any): RouteHandler { +}: { + middleware?: express.RequestHandler[]; + handler: ServiceFunction; +}): RouteHandler { // This function wouldn't be needed if TS had value/object level existential quantification, but since it doesn't we enforce the relationship // between the middleware chain and the handler's input params with this function and then assert the result. return { middleware, handler, [MiddlewareBrand]: true } as RouteHandler;