Skip to content

Make formik helpers types stricter #3362

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

Closed
wants to merge 2 commits into from
Closed

Make formik helpers types stricter #3362

wants to merge 2 commits into from

Conversation

khevamann
Copy link

This PR updates the types of the helpers such as setFieldValues to make sure that only field names that exist in the FormValues type are allowed. Provides better completion as well as error detection.

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2021

⚠️ No Changeset found

Latest commit: 55ad9d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Sep 30, 2021

@khevamann is attempting to deploy a commit to the Formium Team on Vercel.

A member of the Team first needs to authorize it.

@johnrom
Copy link
Collaborator

johnrom commented Nov 29, 2021

This doesn't work for nested fields, you can see WIP #3152 for an example of how TypeScript would need to be used to support nested fields.

@khevamann
Copy link
Author

@johnrom Ok so should I just close this in favor of that PR or make a change to support the nested fields?

@johnrom
Copy link
Collaborator

johnrom commented Nov 30, 2021

I would probably recommend checking out that PR as it has tons and tons of type fixes. You can branch from there and continue trying to get the TS even tighter (I haven't kept up with some of the more recent releases which could have even more powerful methods of typing), or you can test it in development by using this fork

While developing Formik on that branch, the types are a little bit too complex, even though they work pretty well, which results in a bit of development lag. I haven't felt it when actually using the fork in a real project, though.

@khevamann
Copy link
Author

@johnrom I forgot to reply, I looked at the PR you mentioned and it looks like it already handles this typing, so I will close this in favor of that. I may create a few PRs branching from that to try and help with typing

@khevamann khevamann closed this Jan 17, 2022
@khevamann khevamann deleted the patch-1 branch January 17, 2022 01:36
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 this pull request may close these issues.

2 participants