tRPCttRPC
Powered by
alexA
tRPC•4y 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 });
  ...
}
function useSessions(userId: number | null) {
  trpc.sessions.useQuery({ userId }, { enabled: userId !== null });
  ...
}

typescript: Type 'number | null' is not assignable to type 'number'.
typescript: Type 'number | null' is not assignable to type 'number'.
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

type safety with meta
BeanBBean / ❓-help
2y ago
Losing type-safety with merged routers
jacobJjacob / ❓-help
2y ago
Type issue react query with enabled.
wleistraWwleistra / ❓-help
4y ago