Skip to content

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) <[email protected]>

* 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 <[email protected]>
Co-authored-by: Beier (Bill) <[email protected]>
bluebill1049 added a commit that referenced this pull request Apr 21, 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) <[email protected]>

* 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 <[email protected]>
Co-authored-by: Beier (Bill) <[email protected]>
bluebill1049 added a commit that referenced this pull request Jul 5, 2025
* feat: compute prop for useWatch subscription

* clean up initialValue

* update api

* update with unit test

* 👁️ feat: improve reference update with useWatch (#12537)

* feat: improve reference update with useWatch

* update pai extrator

* Revert "update pai extrator"

This reverts commit 0b3bbd3.

* Revert "feat: improve reference update with useWatch"

This reverts commit a664a68.

* update form value reference at consumer isntead usewatch

* update api extrator

* 🐞 fix #12532 useController should unregister issue with strict mode (#12538)

* 7.55.0-next.3

* ⏰ chore: remove __typetest__ folder from build (#12555)

* 🐞 fix useController should unregister issue with strict mode

* chore: remove __typetest__ folder from build

* 🏈 chore: upgrade app and automation deps (#12556)

* chore: upgrade app and automation deps

* update app lock

* revert app package

* 🦾 feat: reference stable for useWatch defaultValue (#12564)

* feat: reference stable for useWatch defaultValue

* remove as

* 🐞 fix #12572 disabled field value not get undefined in resolver (#12573)

* 🐞 fix #12572 disabled field value not get undefined in resolver

* fix resolver data issue

* 7.55.0-next.4

* ❤️ update readme footer for Vercel documentation sponsorship

* 📜 update README.md move banner to the bottom (#12604)

* 😌 close #12606 update package.json author field (#12608)

* 🐞 fix #12580 valid state update with onBlur mode (#12612)

* 🐞 fix #12580 valid state update with onBlur mode

* update e2e

* 🛟 fix: add condition to prevent infinite render (#12622)

* fix: add condition to prevent infinite render

* fix: revert pnpm-lock.yaml changes, and use a utility function instead of typing code manually

* Revert "fix: revert pnpm-lock.yaml changes, and use a utility function instead of typing code manually"

This reverts commit b86e660.

* Revert "fix: add condition to prevent infinite render."

This reverts commit 51105a6.

* fix: use a utility function instead of typing code manually

* 7.55.0-next.5

* 🐞 fix #12580 `setError` in `useEffect` does not work when used inside the `FormProvider` context (#12642)

* 🐞 fix #12632 use useLayoutEffect instead of useEffect to subscribe components earlier than before

* 🧪 test(useFieldArray): Update the result array to reflect the outcomes of the modified logic

* 🧪 test(setError): “Add a test case for using setError within the useEffect callback in FormProvider as mentioned in the issue

* 🦥 close #12634 allow components with `useController` hook be memoized (#12635)

* add test scenario for #12634

* fix(useForm): set `values` immediately on first render

* 🐞 fix #12631 revalidateMode issue with useFieldArray validation (#12646)

* 🚠 upgrade deps and ts to 5.8.0 (#12647)

* upgrade deps and ts to 5.8.0

* app deps upgrade

* update prettier

* Revert "app deps upgrade"

This reverts commit aaabc46.

* update pnpm lock

* 🫡 allow use of `handleSubmit` with native events (#12645)

* Allow use of handleSubmit with native events

* Run API Extractor

---------

Co-authored-by: Beier (Bill) <[email protected]>

* 7.55.0-next.6

* 🐞 fix #12665 regression on values over take default values

* 7.55.0-next.7

* 🥹 close #12665 issue with values not populate form

* 🐞 fix(useForm): make `values` and `defaultValues` work correctly with `createFormControl` and `useMemo` (#12675)

* Revert "🐞 fix #12665 regression on values over take default values"

This reverts commit ef80ff6.

* Revert "🥹 close #12665 issue with values not populate form"

This reverts commit d9e7e4d.

* test: add test case for #12665

* fix(vscode): fix running individual tests and debugging

* test: verify setting values doesn't unregister fields

* fix(createFormControl): don't unregister fields on reset

* fix(useForm): set default values if given along with a form control

Fixes #12665 .

* 👮‍♂️ feat: infer resolver output types (#12638)

* 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) <[email protected]>

* 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 <[email protected]>
Co-authored-by: Beier (Bill) <[email protected]>

* 7.55.0-next.8

* ⚽️ chore: update prettier configuration and apply formatting (#12650)

Co-authored-by: Beier (Bill) <[email protected]>

* 🪲 fix #12680: Update Fieldarray Unmount Status (#12690)

* 🫡 fix: improve type inference for `useFormContext` (#12689)

Co-authored-by: Beier (Bill) <[email protected]>

* 7.55.0-next.9

* 7.55.0

* 🐞 fix: use `useIsomorphicLayoutEffect` to address warning in SSR (#12738)

* ⏰ feat: introduce `isReady` state for subscription (#12568)

* faet: introduce ready state for subscription

* revert change

* save code

* save code

* code consistency

* change to part of formState

* update all unit tests

* update api contract

* update e2e

* fix two more

* update more e2e tests

* remove two blur counter

* fix issue caught by unit tests

* one last e2e test to fix

* update all e2e

* 🌗 feat: support reactive `mode` and `reValidateMode` (#12743)

* feat: support reactive mode and reValidateMode

* minor cleanup

* 🦁 update app deps (#12746)

* wip

* 🐞 fix #12741 regression on move/swap on useFieldArray input update (#12749)

* 🐞 fix #12741 regression on move/swap on useFieldArray input update

* remove unsed code

* simplify the code

* update useFromState

* fix e2e tests

* 7.56.0-next.0

* 7.56.0

* improve other hooks

* update api

* change to useEffect

* rename to consistent value

* update type

* update api contractor

* feat: improve useWatch type when compute prop is specified (#12771)

* Update eslint.config.mjs

* update version

* Revert "update version"

This reverts commit a2711ac.

* 7.57.0-next.0

* update function overload order

* update api contractor

---------

Co-authored-by: KimJunYoung <[email protected]>
Co-authored-by: Jacek Tomaszewski <[email protected]>
Co-authored-by: Josh Kelley <[email protected]>
Co-authored-by: Joris <[email protected]>
Co-authored-by: Jeremy Hughes <[email protected]>
Co-authored-by: HoberMin <[email protected]>
Co-authored-by: David <[email protected]>
Co-authored-by: Kotaro Sugawara <[email protected]>
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