-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Allow resolver output type to truly differ #11951
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
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) <[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]>
* 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]>
* 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]>
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.