Note: This is outdated now that jetpack uses swc-loader
instead of babel
.
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.
To add Flow to a jetpack project, follow these steps:
- Run
npm install --save-dev flow-bin @babel/preset-flow
. - Run
npx flow init
to create a [.flowconfig
file]. - Add
// @flow
to any files you want to type check (for example, tosrc/App.js
). - Create
.babelrc
with the following contents
{
"presets": [
"@babel/preset-flow"
]
}
Now you can run npx flow
to check the files for type errors or run npx jetpack
to run your app as usual.
To learn more about Flow, check out its documentation.