Update flowtype
This commit is contained in:
parent
bf3547d2ec
commit
0f28779fc5
38
flowtype.md
38
flowtype.md
|
@ -43,6 +43,28 @@ Function
|
||||||
Object
|
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)
|
## [Type aliases](https://flowtype.org/docs/quick-reference.html#type-aliases)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -85,11 +107,23 @@ class Foo {
|
||||||
## [Functions](https://flowtype.org/docs/functions.html)
|
## [Functions](https://flowtype.org/docs/functions.html)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function createRenderer (): () => void {
|
const callback: () => void = function () {}
|
||||||
return 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
|
## Examples
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue