https://flow.org/en/docs/getting-started/
npm 安装
npm install --save-dev @babel/core @babel/cli @babel/preset-flow
创建.babelrc
{
"presets": ["@babel/preset-flow"]
}
package.json增加scritp
{
"name": "my-project",
"main": "lib/index.js",
"scripts": {
"build": "babel src/ -d lib/",
"prestart": "npm run build",
"start": "node lib/",
"flow": "flow"
}
}
npm install
npm install --save-dev flow-bin
Add a "flow"
script to your package.json
The first time, run:
npm run flow init
After running flow
with init
the first time, run:
npm run flow
npm run flow: 检查源文件
npm start: 分别运行prestart(build), 然后运行lib/index.js
build目的是strip away Flow types,然后保存到lib目录下