Skip to content

Commit bc69193

Browse files
Merge pull request #179 from bitgopatmcl/narrower-overload-impl
fix: add default param to requestHandler impl
2 parents 8f57485 + cd8772a commit bc69193

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/express-wrapper/src/request.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ export function routeHandler<R extends HttpRoute, Chain extends MiddlewareChain>
6161
}): RouteHandler<R>;
6262

6363
export function routeHandler<R extends HttpRoute>({
64-
middleware,
64+
middleware = [],
6565
handler,
66-
}: any): RouteHandler<R> {
66+
}: {
67+
middleware?: express.RequestHandler[];
68+
handler: ServiceFunction<R, any>;
69+
}): RouteHandler<R> {
6770
// This function wouldn't be needed if TS had value/object level existential quantification, but since it doesn't we enforce the relationship
6871
// between the middleware chain and the handler's input params with this function and then assert the result.
6972
return { middleware, handler, [MiddlewareBrand]: true } as RouteHandler<R>;

0 commit comments

Comments
 (0)