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

Allow resolver output type to truly differ #11951

Conversation

jedahu
Copy link
Contributor

@jedahu jedahu commented May 30, 2024

Removing the TFieldValues constraint from TTransformedValues allows for resolvers to parse to different shaped output types.

Defaulting TTransformValues to TFieldValues instead of undefined means some conditional types can be removed (like those on UseFormHandleSubmit).

I have changed the types only. There are no runtime changes in this PR.

jedahu added 3 commits May 30, 2024 13:14
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.
@Fazla-GroM
Copy link

Any progress on this ?

@jedahu
Copy link
Contributor Author

jedahu commented Sep 29, 2024

It was ready to go but didn't get merged so it's just a case of fixing the conflicts again.

@jorisre
Copy link
Member

jorisre commented Feb 19, 2025

Hi @jedahu
Thank you so much for this PR. I know it's been a while, but if you have some time to resolve the conflicts, I'll test it with the latest version of the resolvers. It could be a very nice improvement!

@bluebill1049
Copy link
Member

I will look at it, and see if I can resolve those conflicts.

@bluebill1049 bluebill1049 changed the base branch from master to main February 22, 2025 23:15
@bluebill1049 bluebill1049 changed the base branch from main to master February 22, 2025 23:15
@bluebill1049 bluebill1049 changed the base branch from master to main February 22, 2025 23:21
@bluebill1049 bluebill1049 merged commit 2e5798e into react-hook-form:main Feb 22, 2025
2 of 6 checks passed
@bluebill1049
Copy link
Member

@jorisre this has never pass the build
image

@Omelyan

This comment has been minimized.

bluebill1049 added a commit that referenced this pull request Mar 13, 2025
* 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>
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.

5 participants