Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to type the form store? #70

Closed
mgcrea opened this issue Jan 27, 2020 · 6 comments · Fixed by #172
Closed

No way to type the form store? #70

mgcrea opened this issue Jan 27, 2020 · 6 comments · Fixed by #172

Comments

@mgcrea
Copy link
Contributor

mgcrea commented Jan 27, 2020

Did not found a documented way to type the store values. Was expecting this API (what's used by react-hook-form):

type FormValues = {
  email: string;
  password: string;
};

const LoginForm: FunctionComponent<Props> = ({history}) => {
  const [form] = Form.useForm<FormValues>();

However useForm does not seem to accept a generic type.

Is there another way to type a form store or do you have another API in mind?

@zombieJ
Copy link
Member

zombieJ commented Feb 3, 2020

hi @mgcrea, do you have interested to improve this?

mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 10, 2020
mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 11, 2020
mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 11, 2020
mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 11, 2020
mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 11, 2020
mgcrea added a commit to mgcrea/field-form that referenced this issue Feb 15, 2020
@Kamahl19
Copy link

Kamahl19 commented Feb 17, 2020

This should also be able without the use of Form.useForm. It could look like

<Form<FormValues> onFinish={}>
</Form>

This works since TypeScript 2.9 https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#generic-type-arguments-in-jsx-elements

@damiangreen
Copy link

This seems like a crucial upgrade, otherwise type safety is lost.

@AnhV90
Copy link

AnhV90 commented Apr 16, 2020

This is driving me crazy since I have to remap every single form field to the type i want, although the types are the same, and I still got a bunch of another forms.

@dongliang1993
Copy link

any updates?

@suncunhu
Copy link

Have a deadline for solving this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants