TanStackT
TanStack12mo ago
5 replies
wispy-olive

How to retrieve type of serverFn's returned data?

I've defined a serverFn like so:
const fetchDataFn = createServerFn({ method: "GET" }).handler(
  async () => { return fetchDataFromDB() }
);


In earlier TanStack versions I was able to do:
type FetchedData = Awaited<ReturnType<typeof fetchDataFn>>

and this worked fine e.g FetchedData was just { message: string } or whatever;

But now, FetchedData is a more complex type: { message: string } | FullFetcherData<undefined, { message: string }>;
Is there maybe a type helper I should be using here?
Was this page helpful?