[英]How to add flowtype to an ejected create-react-app?
We are working on a previously ejected create-react-app
and now want to add flowtype. 我们正在开发以前弹出的
create-react-app
,现在想添加流程类型。
We have followed the guide at: https://flow.org/en/docs/tools/create-react-app/ 我们已按照以下指南进行操作: https : //flow.org/en/docs/tools/create-react-app/
Should that work for an ejected app? 这对弹出的应用程序有用吗?
This has unfortunately caused the webpack-dev server launched with yarn start
to stop automatically reloading on file updates. 不幸的是,这导致了用
yarn start
的webpack-dev服务器在文件更新时停止自动重新加载。
Additionally, after adding // @flow
to some files there is no output or indication of flow enforcing type checking. 此外,在将
// @flow
添加到某些文件后,没有输出或未指示流执行类型检查。
Will we need to manually update the webpack configs? 我们需要手动更新webpack配置吗?
Heres the package.json
scripts 继承人
package.json
脚本
"scripts": {
"start": "node scripts/start.js",
"build": "yarn build-client && yarn build-server",
"build-client": "node scripts/build.js",
"build-server": "./node_modules/.bin/webpack --config ./config/webpack.server.config.js",
"test": "node scripts/test.js --env=jsdom",
},
The output for running yarn start
is: 运行
yarn start
的输出为:
Compiled successfully!
You can now view cra in the browser.
Local: http://localhost:3000/
On Your Network: http://192.168.1.65:3000/
Note that the development build is not optimized.
To create a production build, use yarn build.
The doc you linked tells you how to install the flow-bin and to make a configuration file but don`t tells how to launch it. 您所链接的文档告诉您如何安装流箱并制作配置文件,但不告诉您如何启动它。
Flow is separated tool that should be launch by own command (depends on how you wanna run it): 流是单独的工具,应通过自己的命令启动(取决于您要如何运行):
package.js
: "example-comand-flow": "flow"
. package.js
的“脚本”部分添加npm命令: "example-comand-flow": "flow"
。 Then call it by npm run example-comand-flow
and you`ll get errors directly on a terminal you running the script. npm run example-comand-flow
调用它,您将在运行脚本的终端上直接遇到错误。 Preferences -> Languages & Frameworks -> JavaScript
and set JavaScript language version
to Flow
and specify flow executable. Preferences -> Languages & Frameworks -> JavaScript
,并将JavaScript language version
设置为Flow
并指定流可执行文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.