feat: Split `GetInferenceHelpers` in `Output` and `Input`
See original GitHub issueDescribe the feature you’d like to request
Instead of having inference helpers that expose input and output together, I think we should make two distinct inference helpers
Current:
type RouterTypes = GetInferenceHelpers<AppRouter>;
type Post = RouterTypes['public']['post']['list']['output']['items'][number];
// Getting `items[number]` of `public.post.list.output`
// Hard to read
Describe the solution you’d like to see
Better legibility:
type RouterOutput = GetOutputInferenceHelpers<AppRouter>;
type RouterInput = GetInputInferenceHelpers<AppRouter>;
type Post = RouterOutput['public']['post']['list']['items'][number];
Split inference helpers in two.
Desribe alternate solutions
We could also allow for this, which is even better legibility but will negatively affect TS perf on bigger routers.
Flattened path
type RouterOutput = inferRouterOutput<AppRouter>;
type RouterInput = inferRouterInput<AppRouter>;
type Post = RouterOutput['public.post.list']['items'][number];
Fake representation of a router
@sachinraja brought up this idea as well:
// could be a proxy for a readable error or we could just straight-up lie about the types
const routerOutputs = createRouterOutputTypes<AppRouter>();
const routerInputs = createRouterOutputTypes<AppRouter>();
type Post = typeof routerOutputs.post.byId
It’s arguably a lot nicer for power users, but we do lie about the types.
Additional information
Discussion about naming: https://github.com/trpc/trpc/discussions/2825
👨👧👦 Contributing
- 🙋♂️ Yes, I’d be down to file a PR implementing this feature!
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Splitting - IBM
You can use OUTFIL's SPLIT parameter to put the first record into OUTPUT1, ... With 17 input records, the results produced for OUTPUT1...
Read more >Output / Input - Facebook
Congrats to Output / Input as their cover of The Isley Bro's "Here We Go Again" features on. Expansion Records's Luxury Soul 2023...
Read more >How Computers Work: Input and Output
Input and output may sometimes be separated by time or distance or both. Here are some examples: Factory workers input data by punching...
Read more >Input and output | Think Java | Trinket
This chapter will show you how to read input from the keyboard, use that input to calculate a result, and then format that...
Read more >ESG-inputs vs ESG-outputs and what really matters - LinkedIn
The conclusion of the FT article seems to be that we should split the ESG concept into ESG-input and ESG-output in order to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I would go with option 4:
GetXInferenceHelpersandinferProcedureXGetInferenceHelpersGetXInferenceHelpersOh well, TIL. That being said, between just splitting the inference helpers and using the flattened path (with whichever approach you decide to go with), I very much prefer the flattened path. It’s more readable and faster to work with.