From 962ede5f1cc9b5f2dd54b2ea53d20363afd92bb3 Mon Sep 17 00:00:00 2001 From: Maxime LUCE Date: Thu, 22 Oct 2015 00:52:14 +0200 Subject: [PATCH] Fix HandleFunction typing issue --- connect/connect.d.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/connect/connect.d.ts b/connect/connect.d.ts index 5485d1d81a..a61cd9281e 100644 --- a/connect/connect.d.ts +++ b/connect/connect.d.ts @@ -16,8 +16,13 @@ declare module "connect" { module createServer { export type ServerHandle = HandleFunction | http.Server; - export type HandleFunction = (req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void; - + + export interface HandleFunction { + (req: http.IncomingMessage, res: http.ServerResponse): void; + (req: http.IncomingMessage, res: http.ServerResponse, next: Function): void; + (err: Error, req: http.IncomingMessage, res: http.ServerResponse, next: Function): void; + } + export interface ServerStackItem { route: string; handle: ServerHandle; @@ -25,10 +30,10 @@ declare module "connect" { export interface Server extends NodeJS.EventEmitter { (req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void; - + route: string; stack: ServerStackItem[]; - + /** * Utilize the given middleware `handle` to the given `route`, * defaulting to _/_. This "route" is the mount-point for the @@ -44,7 +49,7 @@ declare module "connect" { */ use(fn: HandleFunction): Server; use(route: string, fn: HandleFunction): Server; - + /** * Handle server requests, punting them down * the middleware stack. @@ -52,8 +57,7 @@ declare module "connect" { * @private */ handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void; - - + /** * Listen for connections. *