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

Replace the Flow documentation section #1245

Merged
merged 1 commit into from
Dec 11, 2016
Merged
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
27 changes: 10 additions & 17 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,28 +444,21 @@ Now you are ready to use the imported React Bootstrap components within your com

## Adding Flow

Flow typing is currently [not supported out of the box](https://github.com/facebookincubator/create-react-app/issues/72) with the default `.flowconfig` generated by Flow. If you run it, you might get errors like this:
Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.

```js
node_modules/fbjs/lib/Deferred.js.flow:60
60: Promise.prototype.done.apply(this._promise, arguments);
^^^^ property `done`. Property not found in
495: declare class Promise<+R> {
^ Promise. See lib: /private/tmp/flow/flowlib_34952d31/core.js:495
Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.

node_modules/fbjs/lib/shallowEqual.js.flow:29
29: return x !== 0 || 1 / (x: $FlowIssue) === 1 / (y: $FlowIssue);
^^^^^^^^^^ identifier `$FlowIssue`. Could not resolve name
```
To add Flow to a Create React App project, follow these steps:

To fix this, change your `.flowconfig` to look like this:
1. Run `npm install --save-dev flow-bin`.
2. Add `"flow": "flow"` to the `scripts` section of your `package.json`.
3. Add `// @flow` to any files you want to type check (for example, to `src/App.js`).

```ini
[ignore]
<PROJECT_ROOT>/node_modules/fbjs/.*
```
Now you can run `npm run flow` to check the files for type errors.
You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience.
In the future we plan to integrate it into Create React App even more closely.

Re-run flow, and you shouldn’t get any extra issues.
To learn more about Flow, check out [its documentation](https://flowtype.org/).

## Adding Custom Environment Variables

Expand Down