Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions to use flow-typed #1067

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
- [Using Global Variables](#using-global-variables)
- [Adding Bootstrap](#adding-bootstrap)
- [Adding Flow](#adding-flow)
- [Jest tests and dependency support](#jest-tests-and-dependency-support)
- [Adding Custom Environment Variables](#adding-custom-environment-variables)
- [Can I Use Decorators?](#can-i-use-decorators)
- [Integrating with a Node Backend](#integrating-with-a-node-backend)
Expand Down Expand Up @@ -452,6 +453,39 @@ To fix this, change your `.flowconfig` to look like this:

Re-run flow, and you shouldn’t get any extra issues.

### Jest tests and dependency support

Flow by itself is not aware of the test runner (jest) and the dependencies you will be using.

In order to load type annotations on those dependencies, you should use [`flow-typed`](https://github.com/flowtype/flow-typed).

First, you need to make `flow-typed` aware of which version of flow you are using, add `flow-bin` to your `package.json`:

```
npm install --save-dev flow-bin
```

Then, install `flow-typed` globally:

```
npm install -g flow-typed
```

You can now install the type definitions:

```
flow-typed install
```

You can re-run this command after each new dependency you add to your project in order to get these annotations.

Now, indicate to flow where to get those annotations by adding the following `[libs]` section to your `.flowconfig`:

```ini
[libs]
./flow-typed
```

## Adding Custom Environment Variables

>Note: this feature is available with `react-scripts@0.2.3` and higher.
Expand Down