Update static-type-checking.md to fix the installation of Flow (#608)
* Update static-type-checking.md to fix the installation of Flow
The second command won't work until the "flow" is added to scripts.
* Update static-type-checking.md
@ -22,25 +22,23 @@ We will explain these steps below in detail.
### Adding Flow to a Project
First, navigate to your project directory in the terminal. You will need to run two commands.
First, navigate to your project directory in the terminal. You will need to run the following command:
If you use [Yarn](https://yarnpkg.com/), run:
```bash
yarn add --dev flow-bin
yarn run flow init
```
If you use [npm](https://www.npmjs.com/), run:
```bash
npm install --save-dev flow-bin
npm run flow init
```
The first command installs the latest version of Flow into your project. The second command creates a Flow configuration file that you will need to commit.
This command installs the latest version of Flow into your project.
Finally, add `flow` to the `"scripts"` section of your `package.json`:
Now, add `flow` to the `"scripts"` section of your `package.json` to be able to use this from the terminal:
```js{4}
{
@ -53,6 +51,22 @@ Finally, add `flow` to the `"scripts"` section of your `package.json`:
}
```
Finally, run one of the following commands:
If you use [Yarn](https://yarnpkg.com/), run:
```bash
yarn run flow init
```
If you use [npm](https://www.npmjs.com/), run:
```bash
npm run flow init
```
This command will create a Flow configuration file that you will need to commit.
### Stripping Flow Syntax from the Compiled Code
Flow extends the JavaScript language with a special syntax for type annotations. However, browsers aren't aware of this syntax, so we need to make sure it doesn't end up in the compiled JavaScript bundle that is sent to the browser.