当我在 Form.create()
中包装一个组件时,Flow错误检查将停止在props上工作 .
组件代码:
// @flow
import React from "react";
import { Form } from "antd";
type Props = {|
requiredField: string,
|};
class MyComponent extends React.Component<Props> {
render() {
return null;
}
}
export default Form.create()(MyComponent);
我在另一个文件中调用此组件:
<MyComponent randomField={15} />
有两个错误:添加了一个不存在的prop randomField
,它省略了所需的prop requiredField.
我希望Flow出现这个错误(当导出未包含在_1676937中时我得到了这个错误:
无法创建MyComponent元素,因为:Props [1]中缺少属性randomField,但在props [2]中存在 . 属性requiredField在props [2]中缺失,但存在于Props [1]中 .
但相反,我没有错误 .
有一个analogous question for TypeScript,有趣的是有相反的问题,错误显示正确使用 . 我尝试使用 FormComponentProps
来实现该问题的最佳答案,但我仍然无法使用错误的用法显示错误 .