diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index 32ad2dcb4b..c72581b8f9 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -13,8 +13,8 @@ var num: number; var str: string; var err: Error; var x: any; -var f: Function; -var func: Function; +var f: (...args: any[]) => any; +var asyncfunc: (...args: any[]) => Promise; var arr: any[]; var exp: RegExp; var anyArr: any[]; @@ -746,7 +746,7 @@ fooProm = Promise.attempt(() => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -func = Promise.method(function () { +asyncfunc = Promise.method(function () { }); @@ -784,8 +784,8 @@ voidProm = Promise.delay(num); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -func = Promise.promisify(f); -func = Promise.promisify(f, obj); +asyncfunc = Promise.promisify(f); +asyncfunc = Promise.promisify(f, obj); obj = Promise.promisifyAll(obj); anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback)); diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 77327127d1..5175bb8d4b 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -609,7 +609,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. */ spread(fulfilledHandler: (...values: W[]) => U | PromiseLike): Bluebird; - spread(fulfilledHandler: Function): Bluebird; + spread(fulfilledHandler: (...args: any[]) => U | PromiseLike): Bluebird; /** * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -695,7 +695,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. * This method is convenient when a function can sometimes return synchronously or throw synchronously. */ - static method(fn: Function): Function; + static method(fn: (...args: any[]) => R | PromiseLike): (...args: any[]) => Bluebird; /** * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. @@ -755,7 +755,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; - static promisify(nodeFunction: Function, options?: Bluebird.PromisifyOptions): Function; + static promisify(nodeFunction: (...args: any[]) => void, options?: Bluebird.PromisifyOptions): (...args: any[]) => Bluebird; /** * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. @@ -777,7 +777,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. */ // TODO fix coroutine GeneratorFunction - static coroutine(generatorFunction: Function): Function; + static coroutine(generatorFunction: (...args: any[]) => IterableIterator): (...args: any[]) => Bluebird; /** * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. @@ -1011,9 +1011,9 @@ declare namespace Bluebird { } export interface PromisifyAllOptions extends PromisifyOptions { suffix?: string; - filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; + filter?: (name: string, func: (...args: any[]) => any, target?: any, passesDefaultFilter?: boolean) => boolean; // The promisifier gets a reference to the original method and should return a function which returns a promise - promisifier?: (originalMethod: Function) => () => PromiseLike; + promisifier?: (originalMethod: (...args: any[]) => any, defaultPromisifer: (...args: any[]) => (...args: any[]) => Bluebird) => () => PromiseLike; } /**