当前位置: 首页 > 工具软件 > Flow > 使用案例 >

javascript with flow

西门良才
2023-12-01

https://flow.org/en/docs/getting-started/

Installation

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"
  }
}

Setup 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目录下

 类似资料:

相关阅读

相关文章

相关问答