Last active
April 25, 2016 13:13
-
-
Save Olical/daa700207b581a1094c18762a5688842 to your computer and use it in GitHub Desktop.
Flow + Babel = <3 or at least a slight improvement
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
// @flow | |
type Person = { | |
name: string, | |
age: number | |
} | |
function getPeople (): Promise<Array<Person>> { | |
const people: Array<Person> = [ | |
{name: 'Foo', age: 21}, | |
{name: 'Bar', age: 31}, | |
{name: 'Baz', age: 41} | |
] | |
return new Promise((resolve) => { | |
setTimeout(resolve(people), 1000) | |
}) | |
} | |
async function run () { | |
const people: Array<Person> = await getPeople() | |
const names: Array<string> = people.map((p: Person) => p.name) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment