11"use client" ;
22
3- import { useQuery } from "@tanstack/react-query" ;
3+ import type { useQuery as useQueryType } from "@tanstack/react-query" ;
44import {
55 type EndpointClient ,
66 createTrpcClientOptions ,
@@ -13,11 +13,11 @@ type TrpcClientWithQuery<R extends Router<any>> = {
1313 ? EndpointClient < Input , Output > & {
1414 useQuery : (
1515 queryOptions ?: Omit <
16- Parameters < typeof useQuery > [ 0 ] ,
16+ Parameters < typeof useQueryType > [ 0 ] ,
1717 "queryKey" | "queryFn"
1818 >
1919 ) => ReturnType <
20- typeof useQuery < Promise < Output > , Error , Promise < Output > , string [ ] >
20+ typeof useQueryType < Promise < Output > , Error , Promise < Output > , string [ ] >
2121 > ;
2222 }
2323 : never ;
@@ -26,7 +26,7 @@ type TrpcClientWithQuery<R extends Router<any>> = {
2626export const createTrpcQueryClient = <
2727 R extends ReturnType < typeof router < any , Router < any > > >
2828> (
29- opts : createTrpcClientOptions
29+ opts : createTrpcClientOptions & { useQuery : typeof useQueryType }
3030) : TrpcClientWithQuery < R > => {
3131 return new Proxy ( { } as TrpcClientWithQuery < R > , {
3232 get ( target , prop ) {
@@ -38,12 +38,12 @@ export const createTrpcQueryClient = <
3838 } ) ,
3939 useQuery : (
4040 queryOptions ?: Omit <
41- Parameters < typeof useQuery > [ 0 ] ,
41+ Parameters < typeof useQueryType > [ 0 ] ,
4242 "queryKey" | "queryFn"
4343 >
4444 ) => {
4545 const endpointName = prop . replace ( / ( [ A - Z ] ) / g, "-$1" ) . toLowerCase ( ) ;
46- return useQuery ( {
46+ return opts . useQuery ( {
4747 ...queryOptions ,
4848 queryKey : [ endpointName ] ,
4949 queryFn : getTrpcFetch ( {
0 commit comments