Merge pull request #1063 from varju/express-signatures

improve express signatures
This commit is contained in:
basarat
2013-09-19 06:01:40 -07:00
+18 -28
View File
@@ -659,13 +659,13 @@ interface ExpressServerResponse {
*
* Aliased as `res.header()`.
*/
set (field: any): void;
set (field: any): ExpressServerResponse;
set (field: string, value?: string): void;
set (field: string, value?: string): ExpressServerResponse;
header(field: any): void;
header(field: any): ExpressServerResponse;
header(field: string, value?: string): void;
header(field: string, value?: string): ExpressServerResponse;
/**
* Get value for header `field`.
@@ -699,11 +699,11 @@ interface ExpressServerResponse {
* // save as above
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
*/
cookie(name: string, val: string, options: CookieOptions);
cookie(name: string, val: string, options: CookieOptions): ExpressServerResponse;
cookie(name: string, val: any, options: CookieOptions);
cookie(name: string, val: any, options: CookieOptions): ExpressServerResponse;
cookie(name: string, val: any);
cookie(name: string, val: any): ExpressServerResponse;
/**
* Set the location header to `url`.
@@ -733,7 +733,7 @@ interface ExpressServerResponse {
*
* @param url
*/
location(url: string);
location(url: string): ExpressServerResponse;
/**
* Redirect to the given `url` with optional response `status`
@@ -767,13 +767,9 @@ interface ExpressServerResponse {
* - `cache` boolean hinting to the engine it should cache
* - `filename` filename of the view being rendered
*/
render(view: string): void;
render(view: string, options?: Object, callback?: (err: Error, html: string) => void ): void;
render(view: string, options: any): void;
render(view: string, callback: (err: Error, html: any) => void ): void;
render(view: string, options: any, callback: (err: Error, html: any) => void ): void;
render(view: string, callback: (err: Error, html: string) => void ): void;
locals: any;
@@ -792,12 +788,12 @@ interface ExpressApplication {
* - setup default middleware
* - setup route reflection methods
*/
init();
init(): void;
/**
* Initialize application configuration.
*/
defaultConfiguration();
defaultConfiguration(): void;
/**
* Proxy `connect#use()` to apply settings to
@@ -1020,9 +1016,9 @@ interface ExpressApplication {
* @param options or fn
* @param fn
*/
render(name: string, options: string, fn: Function);
render(name: string, options?: Object, callback?: (err: Error, html: string) => void ): void;
render(name: string, fn: Function);
render(name: string, callback: (err: Error, html: string) => void ): void;
get(name: string, ...handlers: ExpressRequestFunction[]): any;
get(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
@@ -1061,10 +1057,6 @@ interface ExpressApplication {
listen(handle: any, listeningListener?: Function): void;
render(view: string, callback: (err: Error, html) => void ): void;
render(view: string, optionss: any, callback: (err: Error, html) => void ): void;
route: Route;
router: string;
@@ -1407,11 +1399,9 @@ declare module "express" {
* @param callback or username
* @param realm
*/
export function basicAuth(callback: Function, realm: string);
export function basicAuth(callback: (user: string, pass: string) => boolean, realm?: string): Handler;
export function basicAuth(callback: string, realm: string);
export function basicAuth(callback: Function);
export function basicAuth(user: string, pass: string, realm?: string): Handler;
/**
* Compress:
@@ -1493,7 +1483,7 @@ declare module "express" {
*
* @param options
*/
export function csrf(options: any);
export function csrf(options: any): Handler;
/**
* Directory:
@@ -1542,7 +1532,7 @@ declare module "express" {
* @param path
* @param options
*/
export function favicon(path?: string, options?: any);
export function favicon(path?: string, options?: any): Handler;
/**
* JSON: