File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
apps/content/docs/contract-first Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -112,3 +112,33 @@ export const contract = {
112112 },
113113}
114114```
115+
116+ ## Utilities
117+
118+ ### Infer Contract Router Input
119+
120+ ``` ts twoslash
121+ import type { contract } from ' ./shared/planet'
122+ // ---cut---
123+ import type { InferContractRouterInputs } from ' @orpc/contract'
124+
125+ export type Inputs = InferContractRouterInputs <typeof contract >
126+
127+ type FindPlanetInput = Inputs [' planet' ][' find' ]
128+ ` ` `
129+
130+ This snippet automatically extracts the expected input types for each procedure in the router.
131+
132+ ### Infer Contract Router Output
133+
134+ ` ` ` ts twoslash
135+ import type { contract } from ' ./shared/planet'
136+ // ---cut---
137+ import type { InferContractRouterOutputs } from ' @orpc/contract'
138+
139+ export type Outputs = InferContractRouterOutputs <typeof contract >
140+
141+ type FindPlanetOutput = Outputs [' planet' ][' find' ]
142+ ` ` `
143+
144+ Similarly, this utility infers the output types, ensuring that your application correctly handles the results from each procedure.
You can’t perform that action at this time.
0 commit comments