How to type meta with Generic

I want to pass react hook form useForm return to the meta of the tanstack table.

Doing this

declare module '@tanstack/react-table' {
  interface TableMeta<TData extends RowData> {
    formMethods?: UseFormReturn<any>;
  }
}


It works but type as any doesn't provide any type inference down the road when I use it with the table.


//const formMethods: UseFormReturn<{phoneNumber: string, openingHours: {mo: string, tu: string, we: string, th: string, fr: string, sa: string, su: string}}, any, {phoneNumber: string, openingHours: {mo: string, tu: string, we: string, th: string, fr: string, sa: string, su: string}}>
const formMethods = useForm<{
    phoneNumber: string;
    openingHours: {
      mo: string;
      tu: string;
      we: string;
      th: string;
      fr: string;
      sa: string;
      su: string;
    };
  }>();


<Table 
  ...
  //here formMethods:UseFormReturn<any> | undefined
  meta={{ formMethods }} 
/>


How can I make it so it will infer the type
Was this page helpful?