TanStackT
TanStack13mo ago
8 replies
good-rose

Broken server function type safety?

I have a server function called:

const signInWithGoogle = createServerFn({ method: "POST" })
  .validator((data: unknown) =>
    z.object({ code: z.string(), state: z.string() }).parse(data)
  )
  .handler(async ({ data }) => ...);


data
is typed correctly within the handler but when I call it via:

const { mutateAsync } = useMutation({
  mutationFn: signInWithGoogle,
});
await signInWithGoogle();


no errors are displayed even though the object is required.

What am I doing wrong?
Thanks
Was this page helpful?