Skip to content

Instantly share code, notes, and snippets.

@dbellizzi
Created March 8, 2018 23:54
Show Gist options
  • Save dbellizzi/bdc3e75fbbf5eba916f3232297640de5 to your computer and use it in GitHub Desktop.
Save dbellizzi/bdc3e75fbbf5eba916f3232297640de5 to your computer and use it in GitHub Desktop.
Promise.props and Typescript
import Bluebird = require("bluebird");
interface OneVal {
oneKey1: string,
oneKey2: number,
}
interface TwoVal {
twoKey1: string,
twoKey2: number,
}
const one = (oneProp: string): Promise<OneVal> => {
return Promise.resolve({oneKey1: oneProp, oneKey2: 2});
};
const two = (twoProp: string): Promise<TwoVal> => {
return Promise.resolve({twoKey1: twoProp, twoKey2: 2});
};
const foo = await Bluebird.props({
one: one("oneVal"),
two: two("twoVal"),
});
console.plog("working", foo.one.oneKey1, foo.two.twoKey1);
console.plog("bad", foo.one.oneKey1x, foo.two.twoKey1x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment