AnonTGA
tRPC2w ago
2 replies
AnonTG

How can I infer the trpc.procedure.mutationOptions type?

Hi everyone.

I have this hook that uses the mutation options provided by tRPC. I want the end user to be able to pass the options for the mutation as well. How should I infer the type?

I'm using Node v24.11.1, tRPC v11.8.1 and the new TanStack React Query integration and everything is working fine, except for this issue that I'm stuck on.

I also saw the docs but they only work for the classic integration. The docs for the newer integration doesn't explain this issue.

export function useSomeHook({
    useMutationOptions
}: {
    useMutationOptions?: what should go here?
}) {
    const trpc = useTRPC()
    const result = useMutation(
                // Infer the type that goes in mutationOptions
        trpc.someProcedure.mutationOptions({...useMutationOptions})
    )

    return result
}
Was this page helpful?