Chris Jayden
Chris Jayden2y ago

Typescript helper for router output

is there a helper to do this better? Get the output for a certain route? Or is this the way to do it?
import type { AppRouter } from "$lib/api/root";

type TInitialData = AppRouter['user']['me']['_def']['_output_out']

// Do stuff
import type { AppRouter } from "$lib/api/root";

type TInitialData = AppRouter['user']['me']['_def']['_output_out']

// Do stuff
Solution:
is there a helper to do this better? Get the output for a certain route? Or is this the way to do it? ```ts import type { AppRouter } from "$lib/api/root"; ...
Jump to solution
2 Replies
Chris Jayden
Chris JaydenOP2y ago
Never mind, I should’ve looked better
Chris Jayden
Chris JaydenOP2y ago
Inferring Types | tRPC
It is often useful to access the types of your API within your clients. For this purpose, you are able to infer the types contained in your AppRouter.

Did you find this page helpful?