diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index e616ae3f85..8aef9daa66 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -576,7 +576,6 @@ barProm = fooArrProm.spread((one: Foo, two: Bar, twotwo: Foo) => { //TODO fix collection inference barArrProm = fooProm.all(); -objProm = fooProm.props(); fooInspectionPromise = fooProm.reflect(); barProm = fooProm.any(); barArrProm = fooProm.some(num); @@ -584,6 +583,17 @@ barProm = fooProm.race(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +var propsValue: { num: number, str: string }; +Promise.resolve({ num: 1, str: Promise.resolve('a') }).props().then(val => { propsValue = val }); +Promise.props({ num: 1, str: Promise.resolve('a') }).then(val => { propsValue = val }); +Promise.props(Promise.props({ num: 1, str: Promise.resolve('a') })).then(val => { propsValue = val }); + +var propsMapValue: Map; +Promise.resolve(new Map>()).props().then(val => { propsMapValue = val }); +Promise.props(new Map>()).then(val => { propsMapValue = val }); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Promise.all([fooProm, barProm]).then(result => { result[0].foo(); result[1].bar(); diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 8482e5fe6e..844dad53d4 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -620,8 +620,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - // TODO how to model instance.props()? - props(): Bluebird; + props(this: PromiseLike | V>>): Bluebird>; + props(this: PromiseLike>): Bluebird; /** * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -806,11 +806,13 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * *The original object is not modified.* */ - // TODO verify this is correct // trusted promise for object - static props(object: Bluebird): Bluebird; + static props(map: PromiseLike | V>>): Bluebird>; + static props(object: PromiseLike>): Bluebird; + // map + static props(map: Map | V>): Bluebird>; // object - static props(object: Object): Bluebird; + static props(object: Bluebird.ResolvableProps): Bluebird; /** * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. @@ -1074,6 +1076,8 @@ declare namespace Bluebird { /** @deprecated Use PromiseLike directly. */ export type Thenable = PromiseLike; + export type ResolvableProps = object & { [K in keyof T]: PromiseLike | T[K] }; + export interface Resolver { /** * Returns a reference to the controlled promise that can be passed to clients.