question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript type error when using Form.create({mapPropsToFields}).

See original GitHub issue

Version

3.2.0

Environment

Mac OSX Sierra (10.12.6), Firefox 58.0.2, react 16.2.0, antd 3.2.0

Reproduction link

https://github.com/kevinsperrine/ant-design-form-test

Steps to reproduce

Clone the repo and run yarn start. Minimal repo created using:

create-react-app form-test --scripts-version=react-scripts-ts
yarn add antd

What is expected?

No type errors should occur

What is actually happening?

A Typescript type error that the ‘form’ prop is missing is thrown.

/Users/chuck/Projects/form-test/src/App.tsx
(66,28): Type '{ username: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<CustomFormProps, "username"> & Cust...'.
  Type '{ username: string; }' is not assignable to type 'Readonly<Pick<CustomFormProps, "username"> & CustomFormProps>'.
    Property 'form' is missing in type '{ username: string; }'.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
Nokecycommented, Mar 2, 2018

当 CustomForm 继承React.Component<any, {}> 时 问题依旧 , 如 https://github.com/Nokecy/ant-design-form-test

@yesmeck @benjycui

0reactions
qzmcommented, Dec 5, 2018

Use ‘FormComponentProps’ and ‘export default Form.create()(App);’ It work’s for me


import { Form } from 'antd';
import { FormComponentProps } from 'antd/lib/form';
import { connect } from 'dva';
import * as React from 'react';

export interface IAppProps extends FormComponentProps {
  visible?: boolean;
}

@connect(({ dispatch }) => ({
  dispatch,
}))
class App extends React.PureComponent<IAppProps, any> {
  public render() {
    return <div />
  }
}
export default Form.create()(App);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript build fails when I am trying to create an antd ...
You have to specify types in TypeScript : import { Form } from 'antd'; import { FormComponentProps } from 'antd/lib/form'; ...
Read more >
Form - Ant Design - GitHub Pages
A form consists of one or more form fields whose type includes input, textarea, checkbox, radio, select, tag, and more. A form field...
Read more >
Form - Ant Design
A form consists of one or more form fields whose type includes input, textarea, checkbox, radio, select, tag, and more. A form field...
Read more >
Form - Ant Design
A form consists of one or more form fields whose type includes input, textarea, checkbox, radio, select, tag, and more. A form field...
Read more >
Deciphering TypeScript's React errors | by Fiona Hopkins
When TypeScript complains, its error messages are verbose, with a lot ... The fix: We need to change one or the other of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found