flow all the things

This commit is contained in:
Kent C. Dodds
2018-09-14 22:13:35 -06:00
parent 437ed30ddb
commit d43c846d12
6 changed files with 181 additions and 2 deletions

View File

@@ -7,5 +7,4 @@ if (!('serviceWorker' in navigator)) {
const greeting = 'hello'
console.log(`${greeting} world!`)
;[(1, 2, 3)].forEach(x => console.log(x))

22
src/flow-example.js Normal file
View File

@@ -0,0 +1,22 @@
// @flow
function add(a: number, b: number): number {
return a + b
}
type User = {
name: {
first: string,
middle: string,
last: string,
},
}
function getFullName(user: User): string {
const {
name: {first, middle, last},
} = user
return [first, middle, last].filter(Boolean).join('')
}
add(1, 2)
getFullName({name: {first: 'Joe', middle: 'Bud', last: 'Matthews'}})