Update flowtype

This commit is contained in:
Rico Sta. Cruz 2017-03-16 15:57:23 +08:00
parent bf3547d2ec
commit 0f28779fc5
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 36 additions and 2 deletions

View File

@ -43,6 +43,28 @@ Function
Object
```
## [Dynamic object keys](https://flowtype.org/docs/objects.html#objects-as-maps)
```js
type Items = {
[key: string]: Item
}
```
## [Enums](https://flowtype.org/docs/utility-types.html#keyst)
```js
type Suit = "Diamonds" | "Clubs" | "Hearts" | "Spades"
const countries = {
US: "United States",
IT: "Italy",
FR: "France"
}
type Country = $Keys<typeof countries>
```
## [Type aliases](https://flowtype.org/docs/quick-reference.html#type-aliases)
```js
@ -85,11 +107,23 @@ class Foo {
## [Functions](https://flowtype.org/docs/functions.html)
```js
function createRenderer (): () => void {
return function () { }
const callback: () => void = function () {}
```
```js
function filter<T> (list: Array<T>, callback: (item: T) => boolean): Array<T> {
}
```
## Imports
```js
import type { Person } from '../person'
```
```js
export type Person = { id: string }
```
## Examples