导入时流类型和样式组件错误
Flow type & Styled-components errors when imported
我正在使用 win 7。
代码:
// @flow
import React from 'react';
import styled from 'styled-components';
错误:
... many lines of errors
Error: node_modules/styled-components/lib/utils/create-broadcast.js.flow:20
20: listeners.forEach(listener => listener(currentValue))
^^^^^^^^^^^^ unused
function argument
10: subscribe: (listener: () => void) => () => void
^^^^^^^^^^ function type expects no arguments
Error: node_modules/styled-components/lib/utils/create-broadcast.js.flow:26
26: listener(currentValue)
^^^^^^^^^^^^ unused function argument
10: subscribe: (listener: () => void) => () => void
^^^^^^^^^^ function type expects no arguments
Error: node_modules/styled-components/lib/utils/getComponentName.js.flow:4
4: export default function getComponentName(target: ReactClass<*>): string {
^^^^^^^^^^^^^ identifier `ReactClass`. Could not resolve name
Found 24 errors
error Command failed with exit code 2
.flowconfig:
[ignore]
./build/.*
./node_modules/.*
[include]
[libs]
[lints]
[options]
suppress_comment=.*\$FlowFixMe
[strict]
package.json 文件如下:
"flow-typed": "^2.2.3",
"flow-bin": "^0.59.0",
"styled-components": "2.0.0",
使用了来自 https://github.com/react-boilerplate/react-boilerplate @ 3.5.0
的项目脚手架
我在评论中看到使用 libdef 1.4,但是当我 运行 yarn add --dev flow-typed@1.4 我只得到版本 1 或版本 2.x.x,但没有 1.4。
下一步做什么?
如果您希望流程停止检查 node_modules 您可以在 .flowconfig 中忽略它们或仅包含您的来源文件。
忽略node_modules中的所有内容:
[ignore]
.*/node_modules/.*
关注:
These regular expressions match against absolute paths. They probably should start with .*
更多信息here
我正在使用 win 7。 代码:
// @flow
import React from 'react';
import styled from 'styled-components';
错误:
... many lines of errors Error: node_modules/styled-components/lib/utils/create-broadcast.js.flow:20 20: listeners.forEach(listener => listener(currentValue)) ^^^^^^^^^^^^ unused function argument 10: subscribe: (listener: () => void) => () => void ^^^^^^^^^^ function type expects no arguments Error: node_modules/styled-components/lib/utils/create-broadcast.js.flow:26 26: listener(currentValue) ^^^^^^^^^^^^ unused function argument 10: subscribe: (listener: () => void) => () => void ^^^^^^^^^^ function type expects no arguments Error: node_modules/styled-components/lib/utils/getComponentName.js.flow:4 4: export default function getComponentName(target: ReactClass<*>): string { ^^^^^^^^^^^^^ identifier `ReactClass`. Could not resolve name Found 24 errors error Command failed with exit code 2
.flowconfig:
[ignore]
./build/.*
./node_modules/.*
[include]
[libs]
[lints]
[options]
suppress_comment=.*\$FlowFixMe
[strict]
package.json 文件如下:
"flow-typed": "^2.2.3",
"flow-bin": "^0.59.0",
"styled-components": "2.0.0",
使用了来自 https://github.com/react-boilerplate/react-boilerplate @ 3.5.0
的项目脚手架我在评论中看到使用 libdef 1.4,但是当我 运行 yarn add --dev flow-typed@1.4 我只得到版本 1 或版本 2.x.x,但没有 1.4。
下一步做什么?
如果您希望流程停止检查 node_modules 您可以在 .flowconfig 中忽略它们或仅包含您的来源文件。
忽略node_modules中的所有内容:
[ignore]
.*/node_modules/.*
关注:
These regular expressions match against absolute paths. They probably should start with .*
更多信息here