Skip to content

Commit a57dc33

Browse files
committed
fix: typing issue in the createTrpcQueryClient returned type
1 parent 43daaef commit a57dc33

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

example/trpc/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import "client-only";
22

33
import { createTrpcQueryClient } from "../../src/create-trpc-query-client";
44
import { type AppRouter } from "./router";
5+
import { useQuery } from "@tanstack/react-query";
56

67
const url = "http://localhost:3000/api/trpc";
78

89
export const clientTrpc: ReturnType<typeof createTrpcQueryClient<AppRouter>> = createTrpcQueryClient<AppRouter>({
910
url,
11+
useQuery
1012
});

example/trpc/router.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export const createContext = async () => {
1010

1111
const ctx = new CtxRouter<Awaited<ReturnType<typeof createContext>>>();
1212

13+
interface MockUser {
14+
id:string,
15+
name:string,
16+
email:string,
17+
avatar:string
18+
}
1319
export const appRouter = ctx.router({
1420
getUser: ctx.endpoint.action(async ({ hello, howAreYou, request }) => {
1521
console.log({
@@ -20,7 +26,7 @@ export const appRouter = ctx.router({
2026
nextjsRequest: request,
2127
});
2228

23-
return new Promise((resolve) => {
29+
return new Promise<MockUser>((resolve) => {
2430
setTimeout(() => {
2531
resolve({
2632
id: "1",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@creatorem/next-trpc",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/creatorem/next-trpc"

src/create-trpc-query-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type TrpcClientWithQuery<R extends Router<any>> = {
1717
"queryKey" | "queryFn"
1818
>
1919
) => ReturnType<
20-
typeof useQueryType<Promise<Output>, Error, Promise<Output>, string[]>
20+
typeof useQueryType<Output, Error, Output, string[]>
2121
>;
2222
}
2323
: never;

0 commit comments

Comments
 (0)