我在/flow-typed/redux.flow.js
中定义了全局类型:
declare type Action = {|
+type: string,
+payload: any,
|}
declare type State = {|
+ui: UI,
+user: User,
+team: Team,
+projects: Project[],
+profile: Profile,
|}
declare type UI = {|
+isSliderOpen: boolean,
+isModalVisible: boolean,
+modalAction: string,
+modalPayload: Object,
|}
...
我在我的项目中添加了airbnb eslint配置,现在我得到了:
type Props = {
logout: () => Action, //error ESLint 'Action' is not defined.(no-undef)
user: UserDetails, //error ESLint 'UserDetails' is not defined.(no-undef)
}
它纯粹的隐蔽性错误。一切都被正确地配置,流本身也是快乐的。
如何告诉埃林特,这些类型确实被宣布为全局的?或者我应该把它们添加到一些忽略列表中?
发布于 2017-07-15 16:11:32
结果(就像我想的那样),不添加全局类型到eslint忽略列表。实际上,它都是由我已经安装的插入式流型处理的,但我并没有像这样扩展它:
.eslintrc
"extends": ["airbnb", "plugin:flowtype/recommended"],
"plugins": [
"flowtype"
],
发布于 2017-07-13 20:10:49
您可以使用文件内的注释、eslint配置文件或package.json定义全局变量。阅读如何在eslint文档中这样做。如果你需要更多的帮助,请留下评论。
https://stackoverflow.com/questions/45089144
复制相似问题