【发布时间】:2017-08-16 08:58:23
【问题描述】:
我刚开始使用类型化 JS,目前只是导出/导入我的类型。在查找了一些东西之后,我认为正确的解决方案似乎是“声明”的想法。
阅读 [https://flowtype.org/docs/declarations.html#pointing-your-project-to-declarations] 后,我尝试了“.flowconfig”样式。
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/
但是,所有类型都会出现未定义的错误,例如“连接”未定义。
我错过了什么吗?
【问题讨论】:
-
你在使用 ESLint 吗?