flow: teach type inference

This commit is contained in:
Rico Sta. Cruz 2017-09-21 13:10:14 +08:00
parent e217dc3c9f
commit 72cb1f9b78
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 11 additions and 0 deletions

11
flow.md
View File

@ -26,6 +26,17 @@ Most of what you need to do is to simply add annotations to function arguments!
See: [flow.org docs](https://flow.org/en/docs/) See: [flow.org docs](https://flow.org/en/docs/)
### Type inference
```js
function square (n: number) {
const result = n * n
}
```
{: data-line="2"}
`result` is inferred to be a number because `number * number` will result in a number. There's no need to give it annotations.
### Type aliases ### Type aliases
```js ```js