Created
March 8, 2018 23:54
-
-
Save dbellizzi/bdc3e75fbbf5eba916f3232297640de5 to your computer and use it in GitHub Desktop.
Promise.props and Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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