我正在逐步将base类型引入我们的react/es7代码库。
运行flow不再会产生错误,这是非常好的。但我很困惑为什么某些台词没有被覆盖。
这是flow coverage --json的输出。屏幕截图捕捉了一些常见的报道问题。

1.流类型已经覆盖的类型仍然没有被使用(第6行):我有flow-typed install react-bootstrap,我可以确认./flow-typed/npm/react-bootstrap_v0.32.x.js和./flow-typed/npm/react-boothstrap_vx.x.x.js的存在。
$ fd react-bootstrap ./flow-typed
flow-typed/npm/react-bootstrap_v0.32.x.js
flow-typed/npm/react-bootstrap_vx.x.x.js2.自定义库定义文件不被拾取(第8-9行):.我添加了以下定义文件,并确保它在.flowconfig的[libs]部分中使用。
declare module "@fortawesome/fontawesome-common-types" {
declare type IconDefinition = { icon: Array<mixed> };
}
declare module "@fontawesome/react-fontawesome" {
import type { IconDefinition } from "@fortawesome/fontawesome-common-types";
import type { Component } from "react";
declare export class FontAwesomeIcon extends React$Component<{
icon: IconDefinition,
...
}> {}
}我的.flowconfig如下:
$ cat .flowconfig
[lints]
all=warn
[include]
frontend
[ignore]
# Run `flow ls` to get a list of all files visible to flow
.*/frontend/admin/.*
[libs]
flow-typed
node_modules/fbjs/flow/lib
frontend/types
[untyped]
[options]
module.file_ext=.js
module.file_ext=.jsx
module.system.node.allow_root_relative=true
module.system.node.root_relative_dirname=./frontend
log.file=/tmp/flowtype.log
esproposal.decorators=ignore
# Flowtype doesn't support using css in jsx.
# https://gist.github.com/lambdahands/d19e0da96285b749f0ef
module.name_mapper='.*\(.css\)' -> 'empty/object'EditorContextualProps已在editor/types.jsx中定义如下:export type EditorContextualProps = {|
orderItem: OrderItem,
zoomLevel: ZoomLevel,
...EditorContextualProps,
...OrderItemEditCallbacks,
...PhotoEditCallbacks,
handleCloseModal: () => void
|};4.未使用其他文件中定义的类(第27行):orderItem: OrderItem已在名为order_item.js的文件中定义,如下所示:
export default class OrderItem {
id: string;
product: string;
size: string;
props: { [string]: ?string };
options: Array<string>;
quantity: number;
photos: Array<Photo>;
subtotal: string;
...
}谢谢你读了这么多。干杯。
发布于 2020-08-30 03:49:41
flow-typed/npm/react-bootstrap_vx.x.x.js。这看起来像一个存根,它可能与0.32.0冲突吗?您可能想要删除这一点,它应该解决没有得到任何类型的覆盖。@fontawesome/react-fontawesome而不是@fortawesome/react-fontawesome。EditorContextualProps扩展到自身,尽管可以使用类OrderItem作为类型,但类的语法是使用半类型和半类语法。如果您能够稍微细化示例或更新您的问题以包含试流,那么它可以帮助您绘制出更好的画面。
https://stackoverflow.com/questions/63311107
复制相似问题