flow all the things
This commit is contained in:
@@ -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
22
src/flow-example.js
Normal 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'}})
|
||||
Reference in New Issue
Block a user