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 daa7b6cd0f..3bfe0a7daf 100644 --- a/express-serve-static-core/express-serve-static-core.d.ts +++ b/express-serve-static-core/express-serve-static-core.d.ts @@ -29,9 +29,9 @@ declare module "express-serve-static-core" { (err: any, req: Request, res: Response, next: NextFunction): any; } - type PathParams = string | RegExp | (string | RegExp)[] + type PathParams = string | RegExp | (string | RegExp)[]; - type RequestHandlerParams = RequestHandler | ErrorRequestHandler + type RequestHandlerParams = RequestHandler | ErrorRequestHandler; interface IRouterMatcher { (path: PathParams, ...handlers: RequestHandler[]): T; @@ -73,11 +73,12 @@ declare module "express-serve-static-core" { * @param name * @param fn */ - param(name: string | string[], handler: RequestParamHandler): this; - param(name: string | string[], matcher: RegExp): this; - param(name: string | string[], mapper: (param: any) => any): this; - // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API - param(callback: (name: string, matcher: RegExp) => RequestParamHandler): this; + param: { + (name: string, handler: RequestParamHandler): this; + // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API + // deprecated since express 4.11.0 + (callback: (name: string, matcher: RegExp) => RequestParamHandler): this; + }; /** * Special-cased "all" method, applying the given route `path`, @@ -807,7 +808,7 @@ declare module "express-serve-static-core" { interface Handler extends RequestHandler { } interface RequestParamHandler { - (req: Request, res: Response, next: NextFunction, param: any): any; + (req: Request, res: Response, next: NextFunction, value: any, name: string): any; } interface Application extends IRouter, Express.Application { @@ -872,6 +873,13 @@ declare module "express-serve-static-core" { */ set(setting: string, val: any): Application; get: {(name: string): any;} & IRouterMatcher; + + param: { + (name: string | string[], handler: RequestParamHandler): this; + // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API + // deprecated since express 4.11.0 + param(callback: (name: string, matcher: RegExp) => RequestParamHandler): this; + }; /** * Return the app's absolute pathname