React native 流为新项目生成许多错误
Flow似乎会在新项目中产生很多错误。我做错了什么 我所做的:React native 流为新项目生成许多错误,react-native,flowtype,React Native,Flowtype,Flow似乎会在新项目中产生很多错误。我做错了什么 我所做的: 使用React Native init FlowProject 跟随 纱线添加--开发巴别塔cli巴别塔预设流程 纱线添加——开发流程箱 Ran纱线运行流(.flowconfig由init生成) 以下是我得到的错误: .flowconfig:53 Unsupported option specified! (unsafe.enable_getters_and_setters) error Command failed wit
- 使用
React Native init FlowProject
- 跟随
纱线添加--开发巴别塔cli巴别塔预设流程
纱线添加——开发流程箱
- Ran
(.flowconfig由init生成)纱线运行流
.flowconfig:53 Unsupported option specified! (unsafe.enable_getters_and_setters)
error Command failed with exit code 8.
现在,如果删除指定的行(和版本号),则会出现以下两个错误:
Error: node_modules/react-native/Libraries/Inspector/Inspector.js:104
104: clearTimeout(_hideWait);
^^^^^^^^^ null. This type is incompatible with the expected param type of
733: declare function clearTimeout(timeoutId?: TimeoutID): void;
^^^^^^^^^ TimeoutID. See lib: /private/tmp/flow/flowlib_171966cc/core.js:733
Error: node_modules/react-native/Libraries/Lists/VirtualizedList.js:1094
1094: this.props.onEndReachedThreshold * visibleLength / 2;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined. The operand of an arithmetic operation must be a number.
Found 19 errors
error Command failed with exit code 2.
如果我删除生成的.flowconfig文件(请参见末尾),使用warn run flow init
重新创建它,然后再次运行warn run flow
,我会得到以下错误(我只是显示这5个错误,它们中的大多数彼此相似):
生成的.flowconfig文件
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; Ignore polyfills
.*/Libraries/polyfills/.*
; Ignore metro
.*/node_modules/metro/.*
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/
[options]
emoji=true
module.system=haste
munge_underscores=true
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
unsafe.enable_getters_and_setters=true
[version]
^0.61.0
[忽略]
; 我们用平台叉出一些组件
.*/*[.]android.js
; 忽略“BUCK”生成的dir
/\巴克先生/
; 忽略意外的额外“@providesModule”
*/node\u modules/*/node\u modules/fbjs/*
; 忽略重复的模块提供程序
; 对于通过npm安装的RN应用程序,“库”文件夹位于
; “node_modules/react native”,但在源repo中它位于根目录中
*/Libraries/react native/react.js
; 忽略多边形填充
.*/Libraries/polyfills/*
; 忽略地铁
.*/node_modules/metro/*
[包括]
[图书馆]
node_modules/react native/Libraries/react native/react-native-interface.js
节点\单元模块/反应本机/流程/
节点\模块/反应本机/流github/
[选项]
表情符号=真
模块系统=haste
munge_下划线=真
模块名称映射器='^[/a-zA-Z0-9$-]+.\(bmp\'gif\'jpg\'jpeg\'png\'psd\'svg\'webp\'m4v\'mov\'mp4\'mpeg\'mpg\'webm\'aac\'aiff\'caf\'m4a\'mp3\'WAVA\'html\'pdf\'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
抑制类型=$FlowIssue
抑制类型=$FlowFixMe
抑制类型=$FlowFixMeProps
抑制类型=$FlowFixMeState
禁止评论=\(.\\\\\\n\\)*\$FlowFixMe\\($\\\\\\\\\\\)(\(\)?*\(站点=[a-z,\]*反应\u原生[a-z,\]*\)\)
禁止评论=\(.\\\\\n\)*\$FlowIssue\(\\(\\)?*\(站点=[a-z,\]*react\[a-z,\]*\)?):?[0-9]+
抑制\u注释=\\(.\\\124;\ n\\)*\\$FlowFixedInxtDeploy
抑制\u注释=\\(.\\\124;\ n\\)*\\$FlowExpectedError
不安全。启用\u getters\u和\u setters=true
[版本]
^0.61.0
您不能删除React Native.flowconfig
,因为它定义了许多自定义配置,项目需要这些配置才能清楚地进行类型检查
让我们看一下初始错误:
.flowconfig:53指定了不受支持的选项!(不安全。启用\u getter\u和\u setter)
错误命令失败,退出代码为8
这是由于使用warn add Flow bin
安装的Flow版本不再支持此选项(以前是)。您需要安装.flowconfig最后一行中定义的确切版本的Flow
[version]
^0.61.0
您可以通过以下方式执行此操作:
yarn add flow-bin@0.61
现在,项目应该正确地进行类型检查
请注意,在将来,如果您使用react native upgrade
升级项目模板,并接受对.flowconfig
的更改,则可能需要手动升级您的flow bin
依赖项以匹配。发现此半相关项,建议更新flowconfig以使用或者我
[version]
^0.61.0
yarn add flow-bin@0.61