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

Update useForm types to accept interfaces #1646

Closed
wants to merge 1 commit into from

Conversation

thecrypticace
Copy link
Contributor

Previously a bare interface type that does not extend Record<string, unknown> was not accepted. This isn't ideal so this PR makes changes such that we are able to accept arbitrary interface types but still get validation when using useForm(). Since we still want to do some validation on the types we use a conditional type in parameter position to validate that the data being passed through is correct. This isn’t the most ideal solution because the errors highlight the entire object instead of individual keys but it is an improvement over the status quo.

Fixes #1624
Closes #1626

We still want to do some validation on the types so we use a conditional type in parameter position to validate that the data being passed through is correct. This isn’t the most ideal solution because the errors highlight the entire object instead of individual keys but it is an improvement over the status quo.
@jessarcher jessarcher force-pushed the fix/use-form-interface-types branch from d04f97c to 08664ac Compare August 16, 2023 03:34
@reinink
Copy link
Member

reinink commented Aug 17, 2023

Hey @thecrypticace, as we discussed, closing this in favor of #1649. Thanks for taking a crack at it buddy! 💪

@reinink reinink closed this Aug 17, 2023
@reinink reinink deleted the fix/use-form-interface-types branch August 17, 2023 12:05
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.

React TypeScript: useForm's generic is forcing to use type where interface won't work
2 participants