mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Made Q have better generics support made possible be v0.9.0.1. Also eliminated redundant function definitions in express.
This commit is contained in:
Vendored
+12
-219
@@ -780,6 +780,10 @@ interface ExpressServerResponse {
|
||||
charset: string;
|
||||
}
|
||||
|
||||
interface ExpressRequestFunction {
|
||||
(req: ExpressServerRequest, res: ExpressServerResponse, next: Function): any;
|
||||
}
|
||||
|
||||
interface ExpressApplication {
|
||||
/**
|
||||
* Initialize the server.
|
||||
@@ -1020,228 +1024,17 @@ interface ExpressApplication {
|
||||
|
||||
render(name: string, fn: Function);
|
||||
|
||||
get (name: string): any;
|
||||
get(name: string, ...handlers: ExpressRequestFunction[]): any;
|
||||
get(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
|
||||
|
||||
get (name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
post(name: string, ...handlers: ExpressRequestFunction[]): any;
|
||||
post(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
|
||||
|
||||
get (name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
put(name: string, ...handlers: ExpressRequestFunction[]): any;
|
||||
put(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
|
||||
|
||||
get (name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
get (name: RegExp): any;
|
||||
|
||||
get (name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
get (name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
post(name: string): any;
|
||||
|
||||
post(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
post(name: RegExp): any;
|
||||
|
||||
post(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
post(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
put(name: string): any;
|
||||
|
||||
put(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
put(name: RegExp): any;
|
||||
|
||||
put(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
put(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
del(name: string): any;
|
||||
|
||||
del(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: string,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
|
||||
del(name: RegExp): any;
|
||||
|
||||
del(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
|
||||
|
||||
del(name: RegExp,
|
||||
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
|
||||
...handlers: any[]): any;
|
||||
del(name: string, ...handlers: ExpressRequestFunction[]): any;
|
||||
del(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
|
||||
|
||||
/**
|
||||
* Listen for connections.
|
||||
|
||||
+24
-9
@@ -1,3 +1,4 @@
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
/// <reference path="Q.d.ts" />
|
||||
|
||||
import q = module('q');
|
||||
@@ -40,14 +41,14 @@ Q.all([
|
||||
|
||||
|
||||
Q.fcall(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function (value4) {
|
||||
// Do something with value4
|
||||
}, function (error) {
|
||||
// Handle any error from step1 through step4
|
||||
}).done();
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function (value4) {
|
||||
// Do something with value4
|
||||
}, function (error) {
|
||||
// Handle any error from step1 through step4
|
||||
}).done();
|
||||
|
||||
Q.allResolved([])
|
||||
.then(function (promises: Q.Promise<any>[]) {
|
||||
@@ -58,4 +59,18 @@ Q.allResolved([])
|
||||
var exception = promise.valueOf().exception;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
declare var arrayPromise: Q.IPromise<number[]>;
|
||||
declare var stringPromise: Q.IPromise<string>;
|
||||
declare function returnsNumPromise(text: string): Q.Promise<number>;
|
||||
|
||||
Q<number[]>(arrayPromise) // type specification required
|
||||
.then(arr => arr.join(','))
|
||||
.then<number>(returnsNumPromise) // requires specification
|
||||
.then(num => num.toFixed());
|
||||
|
||||
declare var jPromise: JQueryPromise;
|
||||
|
||||
// if jQuery promises definition supported generics, this could be more interesting example
|
||||
Q<any>(jPromise).then((val) => val.toExponential());
|
||||
@@ -3,9 +3,17 @@
|
||||
// Definitions by: Barrie Nemetchek, Andrew Gaspar
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare function Q<T>(value): Q.Promise<T>;
|
||||
declare function Q<T>(value: T): Q.Promise<T>;
|
||||
declare function Q<T>(promise: Q.IPromise<T>): Q.Promise<T>;
|
||||
|
||||
declare module Q {
|
||||
interface IPromise<T> {
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => U): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => U): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => IPromise<U>): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => IPromise<U>): IPromise<U>;
|
||||
}
|
||||
|
||||
interface Deferred<T> {
|
||||
promise: Promise<T>;
|
||||
resolve(value: T): any;
|
||||
@@ -18,7 +26,12 @@ declare module Q {
|
||||
fail(errorCallback: Function): Promise<any>;
|
||||
fin(finallyCallback: Function): Promise<T>;
|
||||
finally(finallyCallback: Function): Promise<T>;
|
||||
then(onFulfilled?: (value: T) => any, onRejected?: (reason) => any, onProgress?: Function): Promise<any>;
|
||||
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => U, onProgress?: Function): Promise<U>;
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => U, onProgress?: Function): Promise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => IPromise<U>, onProgress?: Function): Promise<U>;
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => IPromise<U>, onProgress?: Function): Promise<U>;
|
||||
|
||||
spread(onFulfilled: Function, onRejected?: Function): Promise<any>;
|
||||
catch(onRejected: Function): Promise<any>;
|
||||
progress(onProgress: Function): Promise<any>;
|
||||
|
||||
Reference in New Issue
Block a user