From 7007fddc5efd6573eee2bbb6ed526ff967e814c8 Mon Sep 17 00:00:00 2001 From: Artur Eshenbrener Date: Fri, 23 Sep 2016 16:43:52 +0400 Subject: [PATCH] [express]: RequestHandler's 3rd argument fix (#11288) * [express]: RequestHandler's 3rd argument fix It is hot optional. Btw, express instance itself is a request handler, which can be invoked without 3rd argument, so, as for now it has call signature with only 2 arguments: request and response. Fixes #11164 * Move 2-args call signature to Application interface --- express-serve-static-core/express-serve-static-core.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/express-serve-static-core/express-serve-static-core.d.ts b/express-serve-static-core/express-serve-static-core.d.ts index 624ed5ae5d..0371c2bb6a 100644 --- a/express-serve-static-core/express-serve-static-core.d.ts +++ b/express-serve-static-core/express-serve-static-core.d.ts @@ -22,7 +22,7 @@ declare module "express-serve-static-core" { } interface RequestHandler { - (req: Request, res: Response, next?: NextFunction): any; + (req: Request, res: Response, next: NextFunction): any; } interface ErrorRequestHandler { @@ -822,6 +822,12 @@ declare module "express-serve-static-core" { } interface Application extends IRouter, Express.Application { + /** + * Express instance itself is a request handler, which could be invoked without + * third argument. + */ + (req: Request, res: Response): any; + /** * Initialize the server. *