我刚开始输入JS,目前正在导出/导入我的类型。在查了几件事之后,我认为正确的解决办法似乎是“声明”的想法。
在阅读了[https://flowtype.org/docs/declarations.html#pointing-your-project-to-declarations]之后,我尝试了".flowconfig"-style。
decls/types.js
declare type Post = {
feed: Connection,
}
declare type Connection = {
edges: Array<Edge>,
pageInfo: PageInfo,
}
declare type Edge = {
cursor: number,
node: Node,
}
declare type PageInfo = {
endCursor: number,
hasNextPage: boolean,
}
declare type Node = {
id: string,
createdAt: number,
}
然后,我将decls/
目录添加到.flowconfig
[libs]
中。
.flowconfig
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
decls/
但是,所有类型都会出现错误,没有定义错误。没有定义“连接”。
我错过了什么吗?
发布于 2017-03-23 17:01:06
由于您使用的是ESLint,所以需要添加插入式流型扩展并最小化地启用define-flow-type
规则,以便ESLint不将流类型标记为未定义的。
ESLint配置:
{
"plugins": [
"flowtype"
],
"rules": {
"flowtype/define-flow-type": 2
}
}
https://stackoverflow.com/questions/42982254
复制相似问题