Skip to content

Commit 135ee5b

Browse files
feat(t3-app): add inference helper and example usage (#613)
* add inference helper and example usage * my prettier is weird * ??
1 parent 2df4979 commit 135ee5b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/spicy-falcons-poke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-t3-app": minor
3+
---
4+
5+
add inference helper for v10

cli/template/addons/trpc/utils.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// src/utils/trpc.ts
2+
import superjson from "superjson";
3+
24
import { httpBatchLink, loggerLink } from "@trpc/client";
35
import { createTRPCNext } from "@trpc/next";
6+
import type { GetInferenceHelpers } from "@trpc/server";
7+
48
import type { AppRouter } from "../server/trpc/router/_app";
5-
import superjson from "superjson";
69

710
const getBaseUrl = () => {
811
if (typeof window !== "undefined") return ""; // browser should use relative url
@@ -28,3 +31,9 @@ export const trpc = createTRPCNext<AppRouter>({
2831
},
2932
ssr: false,
3033
});
34+
35+
/**
36+
* Inference helpers
37+
* @example type HelloOutput = AppRouterTypes['example']['hello']['output']
38+
**/
39+
export type AppRouterTypes = GetInferenceHelpers<AppRouter>;

0 commit comments

Comments
 (0)