From 05f9cf03f3a9c20ea88fe6fa99ec3d77f12edb64 Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Sun, 20 Nov 2016 21:23:00 +0100 Subject: [PATCH 1/2] Add instructions to use flow-typed --- packages/react-scripts/template/README.md | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 8fd69a5bc0d..55eed450bd9 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -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) @@ -452,6 +453,32 @@ 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. + ## Adding Custom Environment Variables >Note: this feature is available with `react-scripts@0.2.3` and higher. From 4695f071f150b1da592d3c23247ea02e1307299e Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Sun, 20 Nov 2016 21:32:26 +0100 Subject: [PATCH 2/2] Add .flowconfig configuration --- packages/react-scripts/template/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 55eed450bd9..dde4d3c5f56 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -479,6 +479,13 @@ 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.