Как использовать Form.create в машинописи и antd с компонентом функции - PullRequest
2 голосов
/ 24 апреля 2019

У меня есть форма, созданная 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;

Как я могу исправить эту ошибку.

1 Ответ

3 голосов
/ 25 апреля 2019

Я думаю, что это ошибка в определениях TypeScript в Ant Design:
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"), пока исправление не будет развернуто.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...