jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
33.97k stars 2.79k forks source link

[Feature Request] Generic form status #1690

Open doomsower opened 5 years ago

doomsower commented 5 years ago

🚀 Feature request

Current Behavior

Form status has type any

Desired Behavior

I'd like to have strongly typed status.

Suggested Solution

Just add second generic argument to Formik, and then add it everywhere down the chain. It can default to any, so that existing code doesn't break. So it would look like

export function Formik<
  Values extends FormikValues = FormikValues,
  Status = any
>(props: FormikConfig<Values, Status>) {

(I removed ExtraProps here, because they are not used at all, if I'm not mistaken)

If you're ok with this idea, I can submit PR.

Who does this impact? Who is this for?

Those who use Typescript and form status at the same time.

Describe alternatives you've considered

Additional context

outerlook commented 4 years ago

It would be nice! I really miss this.

For example, I'm building a multi step form that is controlled by status, that could be 1 | 2 | 3 or by name which would be better for not trying to remember which step a number represent ("LOCATION" | "PAYMENT" | "MORE INFO" for example).

This typing would be really convenient for that use.