-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow resolver output type to truly differ #11951
Allow resolver output type to truly differ #11951
Conversation
This allows for resolvers to parse to a different type that doesn't have to have the same shape as TFieldValues. This commit contains type-only changes. No runtime changes are introduced.
Test that `useWatch` returns `TFieldValues` values, not `TTransformedValues` ones. Test that `TTransformedValues` are submitted on success and `TFieldValues` on failure.
Any progress on this ? |
It was ready to go but didn't get merged so it's just a case of fixing the conflicts again. |
Hi @jedahu |
I will look at it, and see if I can resolve those conflicts. |
@jorisre this has never pass the build |
This comment has been minimized.
This comment has been minimized.
* Allow resolver output type to truly differ (#11951) * Default TTransformedValues to TFieldValues without constraint This allows for resolvers to parse to a different type that doesn't have to have the same shape as TFieldValues. This commit contains type-only changes. No runtime changes are introduced. * Tests for TTransformedValues change Test that `useWatch` returns `TFieldValues` values, not `TTransformedValues` ones. Test that `TTransformedValues` are submitted on success and `TFieldValues` on failure. * Add type test for useForm inference From: https://github.com/react-hook-form/react-hook-form/pull/11913/files --------- Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com> * feat: add automatic output type inference from resolver functions * fix: resolvers type inference * chore: api extractor * test build * Revert "test build" This reverts commit 16e5661. --------- Co-authored-by: Jeremy Hughes <jedahu@gmail.com> Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
Removing the
TFieldValues
constraint fromTTransformedValues
allows for resolvers to parse to different shaped output types.Defaulting
TTransformValues
toTFieldValues
instead ofundefined
means some conditional types can be removed (like those onUseFormHandleSubmit
).I have changed the types only. There are no runtime changes in this PR.