alexA
tRPC4y ago
18 replies
alex

Type safety with enabled option

https://tkdodo.eu/blog/react-query-and-type-script#type-safety-with-the-enabled-option
What is the best way to solve this with trpc?

function useSessions(userId: number | null) {
  trpc.sessions.useQuery({ userId }, { enabled: userId !== null });
  ...
}

typescript: Type 'number | null' is not assignable to type 'number'.
Was this page helpful?