Skip to content

Commit

Permalink
fix(v5): Fix form types (#5350)
Browse files Browse the repository at this point in the history
* fix(Form): Fix types

* Remove extra props
  • Loading branch information
kyletsang committed Aug 1, 2020
1 parent 5c5e7ec commit 835d397
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export interface FormProps extends React.HTMLAttributes<HTMLElement>, AsProp {
validated?: boolean;
}

type Form = {
type Form = React.ForwardRefExoticComponent<
FormProps & React.RefAttributes<HTMLElement>
> & {
Group: typeof FormGroup;
Control: typeof FormControl;
Check: typeof FormCheck;
Expand All @@ -26,9 +28,6 @@ type Form = {
Text: typeof FormText;
Range: typeof FormRange;
Select: typeof FormSelect;
propTypes?: any;
defaultProps?: Partial<FormProps>;
displayName?: string;
};

const propTypes = {
Expand Down Expand Up @@ -72,7 +71,7 @@ const FormImpl: Form = (React.forwardRef(
) as unknown) as Form;

FormImpl.displayName = 'Form';
FormImpl.propTypes = propTypes;
FormImpl.propTypes = propTypes as any;

FormImpl.Group = FormGroup;
FormImpl.Control = FormControl;
Expand Down
7 changes: 1 addition & 6 deletions tests/simple-types-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,7 @@ const MegaComponent = () => (
style={style}
/>
<Figure.Caption as="figcaption" bsPrefix="figurecaption" />
<Form
ref={React.createRef<HTMLFormElement>()}
as="form"
validated
bsPrefix="form"
>
<Form ref={React.createRef<HTMLFormElement>()} as="form" validated>
<Form.Group
ref={React.createRef<HTMLDivElement>()}
as="div"
Expand Down

0 comments on commit 835d397

Please sign in to comment.