我有一个由Form.create()创建的表单,但我无法编译成功。
错误如:
Argument of type 'FunctionComponent<MyProps>' is not assignable to parameter of type 'ComponentType<{}>'.
Type 'FunctionComponent<MyProps>' is not assignable to type 'FunctionComponent<{}>'.
Type '{}' is missing the following properties from type 'MyProps': form, and 2 more
我的代码是:
import { FormComponentProps } from "antd/lib/form";
interface MyProps extends FormComponentProps {
form: any;
}
const TableQuery: FunctionComponent<MyProps> = (props: MyProps) => {
// some code
};
const WrappedTableQuery = Form.create<MyProps>()(TableQuery)
export default WrappedTableQuery;
我该如何解决这个错误。
我认为这是Ant Design中TypeScript定义的一个错误: https://github.com/ant-design/ant-design/issues/16229(中文) https://github.com/ant-design/ant-design/issues/16095#issuecomment-485709670(英文)
它出现在3.16.4版本(发布于2019-04-21),它仍然存在于版本3.16.5中。
您可以使用以前的版本("antd": "3.16.3"
),直到部署修复程序。