Repository: react-hook-form/react-hook-form (TypeScript)

Issue:
issue: next.8 handleSubmit on useFormContext does not infer types of data correctly
### Version Number

7.55.0-next.8

### Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/icy-river-v25p6s

### Steps to reproduce

Check the types in the codesandbox, they are not correctly infer the form data values


### Expected behaviour

Should be able to infer the data correctly


### Code of Conduct

- [x] I agree to follow this project's Code of Conduct


Discussion:
This is a typescript issue I am facing after using `handleSubmit` on `useFormContext`

<img width="603" alt="Image" src="https://github.com/user-attachments/assets/6c195ea4-9422-4353-b8f9-8762ede3f293" />
@jorisre looks like this breaks the type infer on useFormContext



Patch:
diff --git a/reports/api-extractor.md.api.md b/reports/api-extractor.md.api.md
index 1df6dd9abf0..90d00495896 100644
--- a/reports/api-extractor.md.api.md
+++ b/reports/api-extractor.md.api.md
@@ -661,7 +661,7 @@ export function useForm<TFieldValues extends FieldValues = FieldValues, TContext
 export type UseFormClearErrors<TFieldValues extends FieldValues> = (name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[] | `root.${string}` | 'root') => void;
 
 // @public
-export const useFormContext: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = undefined>() => UseFormReturn<TFieldValues, TContext, TTransformedValues>;
+export const useFormContext: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>() => UseFormReturn<TFieldValues, TContext, TTransformedValues>;
 
 // @public
 export type UseFormGetFieldState<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues>>(name: TFieldName, formState?: FormState<TFieldValues>) => {
diff --git a/src/useFormContext.tsx b/src/useFormContext.tsx
index e939c988edb..7da40f7bd07 100644
--- a/src/useFormContext.tsx
+++ b/src/useFormContext.tsx
@@ -37,7 +37,7 @@ const HookFormContext = React.createContext<UseFormReturn | null>(null);
 export const useFormContext = <
   TFieldValues extends FieldValues,
   TContext = any,
-  TTransformedValues = undefined,
+  TTransformedValues = TFieldValues,
 >(): UseFormReturn<TFieldValues, TContext, TTransformedValues> =>
   React.useContext(HookFormContext) as UseFormReturn<
     TFieldValues,


Test patch:
diff --git a/src/__typetest__/use-form-context.test-d.ts b/src/__typetest__/use-form-context.test-d.ts
new file mode 100644
index 00000000000..64aed131512
--- /dev/null
+++ b/src/__typetest__/use-form-context.test-d.ts
@@ -0,0 +1,33 @@
+import { expectType } from 'tsd';
+
+import { useFormContext } from '../useFormContext';
+
+/** it should correctly infer the output type from useFormContext */ {
+  type Input = {
+    test: string;
+  };
+
+  /* eslint-disable react-hooks/rules-of-hooks */
+  const { handleSubmit } = useFormContext<Input>();
+
+  handleSubmit((data) => {
+    expectType<Input>(data);
+  });
+}
+
+/** it should correctly infer the output type from useFormContext with different output type */ {
+  type Input = {
+    test: string;
+  };
+
+  type Output = {
+    test: number;
+  };
+
+  /* eslint-disable react-hooks/rules-of-hooks */
+  const { handleSubmit } = useFormContext<Input, any, Output>();
+
+  handleSubmit((data) => {
+    expectType<Output>(data);
+  });
+}