浏览 97
分享
Adding Flow
Flow is a static type checker that helps you write code with fewer bugs. Check out this introduction to using static types in JavaScript if you are new to this concept.
Recent versions of Flow work with Create React App projects out of the box.
To add Flow to a Create React App project, follow these steps:
- Run
npm install —save flow-bin
(oryarn add flow-bin
). - Add
"flow": "flow"
to thescripts
section of yourpackage.json
. - Run
npm run flow init
(oryarn flow init
) to create a.flowconfig
file in the root directory. - Add
// @flow
to any files you want to type check (for example, tosrc/App.js
).Now you can runnpm run flow
(oryarn flow
) to check the files for type errors.You can optionally use an IDE like Nuclide for a better integrated experience.In the future we plan to integrate it into Create React App even more closely.
To learn more about Flow, check out its documentation.
评论列表