TanStackT
TanStack3y ago
2 replies
technological-jade

Using tRPC inferred types with Tanstack Table?

Hey all!!!

I am currently trying to use tRPC to grab a sample of data from my backend to use in tanstack table

I had a previous verison of this working where I used an explicitly types API route, however I want to be able to infer the type of the route and use it as the type for the column defs

I was wondering if anyone has tried to do this or something similar. The main problem I am having is with the columns field when using the useReactTable hook. It seems that the main complaint from typescript is a missing dependency of Accessorfn

https://trpc.io/docs/client/react/infer-types

I am using the link above to infer the types returned by my API route.

https://tanstack.com/table/v8/docs/guide/column-defs

and the link above to setup my column helper
In addition to the type inference made available by @trpc/server (see here) this integration also provides some inference helpers for usage purely in React.
Inferring Types | tRPC
Was this page helpful?