jaredpalmer / jaredpalmer/formik

`FieldProps` type is not accepting proper generic type.

Open
#1,998 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
TypeScript
Stars
34.3k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

🐛 Bug report

https://github.com/jaredpalmer/formik/blob/7b0752a73ad1676ed88e92ca49f2e7341cce4413/src/Field.tsx#L13

Current Behavior

FieldProps type accepts just one generic type where it uses same type both for field and form values. I think it is not correct behavior.

Expected behavior

Expected behavior is that FieldProps should accept 2 generic type.

Suggested solution(s)

It should accept 2 types, one for meta and field, another one for form key like below.

export interface FieldProps<V = any, FV = any> {
  field: FieldInputProps<V>;
  form: FormikProps<FV>;
  meta: FieldMetaProps<V>;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/Field.tsx line 13, where FieldProps is defined, and inspect the related FieldInputProps, FormikProps, and FieldMetaProps types. Confirm the generic relationships and verify that FieldProps can represent distinct field/meta and form value types; done when the type definition and relevant type checks support the reported usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.