Improved Form component typings (#10564)

* Improved Form component typings

With this fix you can use HTMLFormElement attributes on Form component
without getting TypeScript errors.

For example this code does not longer produce error for the additional
`autoComplete` prop:

```
const myForm = (
  <Form autoComplete="off">
    ...
  </Form>
)
```

* Fix onBlur / onChange typings with Input component

This improvement fix a typing issue incompatibility with
`react-final-form`
The incompatibility involve [this
line](https://github.com/final-form/react-final-form/blob/v3.4.2/src/index.d.ts#L20)
where the handler argument is a more specific SyntheticEvent
This commit is contained in:
Walter Barbagallo 2018-05-17 17:45:13 +02:00 committed by 偏右
parent b7d508e166
commit 963120f702
2 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,7 @@ export interface FormCreateOption<T> {
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
export interface FormProps {
export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
layout?: FormLayout;
form?: WrappedFormUtils;
onSubmit?: React.FormEventHandler<any>;

View File

@ -38,8 +38,8 @@ export interface InputProps extends AbstractInputProps {
onKeyUp?: React.FormEventHandler<HTMLInputElement>;
onChange?: React.ChangeEventHandler<HTMLInputElement>;
onClick?: React.FormEventHandler<HTMLInputElement>;
onFocus?: React.FormEventHandler<HTMLInputElement>;
onBlur?: React.FormEventHandler<HTMLInputElement>;
onFocus?: React.FocusEventHandler<HTMLInputElement>;
onBlur?: React.FocusEventHandler<HTMLInputElement>;
autoComplete?: string;
prefix?: React.ReactNode;
suffix?: React.ReactNode;