facebook / facebook/flow

Add more comprehensive documentation for arrow function types

Open
#3,447 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Hi there!

In going over some flowtype annotations we added to our codebase during code review, it came up that:

```
const preventDefault: Event => void = e => e.preventDefault()
```
is seemingly a valid usage of flow. However, all examples outside of the docs have:

```
const preventDefault: (e: Event) => void = e => e.preventDefault()
```

and the docs themselves only point to a model of `(P1: T1): U`

I'd like to propose adding a note in the docs that for arrow function types, parameter name and parenthesis are optional for unary functions (unless this is considered bad practice, then perhaps a note saying that while optional, you should always prefer parens and parameter names in the type sigs)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.