jaredpalmer / jaredpalmer/formik

Enhancer type for setFieldTouched, setFieldValue, setFieldError

Open
#3,901 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
34.3k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

Hi! 👋

Here is the diff that solved my problem:

```diff
diff --git a/node_modules/formik/dist/Formik.d.ts b/node_modules/formik/dist/Formik.d.ts
index 8657eff..968247b 100644
--- a/node_modules/formik/dist/Formik.d.ts
+++ b/node_modules/formik/dist/Formik.d.ts
@@ -18,9 +18,9 @@ export declare function useFormik({
resetForm: (nextState?: Partial> | undefined) => void;
setErrors: (errors: FormikErrors) => void;
setFormikState: (stateOrCb: FormikState | ((state: FormikState) => FormikState)) => void;
- setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean | undefined) => Promise> | Promise;
- setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => Promise> | Promise;
- setFieldError: (field: string, value: string | undefined) => void;
+ setFieldTouched: (field: keyof Values, touched?: boolean, shouldValidate?: boolean | undefined) => Promise> | Promise;
+ setFieldValue: (field: keyof Values, value: any, shouldValidate?: boolean | undefined) => Promise> | Promise;
+ setFieldError: (field: keyof Values, value: string | undefined) => void;
setStatus: (status: any) => void;
setSubmitting: (isSubmitting: boolean) => void;
setTouched: (touched: FormikTouched, shouldValidate?: boolean | undefined) => Promise> | Promise;
```

Contributor guide

Open the contributing guide

Research direction

Start with the API declarations shown in node_modules/formik/dist/Formik.d.ts and trace where these useFormik methods are defined and their types are generated. Confirm that setFieldTouched, setFieldValue, and setFieldError accept keys of Values in the published typings, then run the relevant existing type checks or tests to verify the declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.