Can anyone share how to infer type of class member of trpcresponse

I am using inferRouterOutputs<AppRouter>['abc']['def'] to get the type of response, now I need to get the type of a member of output response , please share if anyone has done this before.
5 Replies
Prabhath
Prabhath2y ago
for the member in childTable, I have used include to fetch the child object, now i am not able to get the type of object of the child table
.hatulapro
.hatulapro2y ago
You can simply do:
RouterOutputs['abc']['def']['someMember']
RouterOutputs['abc']['def']['someMember']
Prabhath
Prabhath2y ago
I get the following error when i do this Property 'subProperty' does not exist on type '(MainProperty & { subProperty: SubProperty[]; }) | null | undefined'
.hatulapro
.hatulapro2y ago
Try wrapping it with NonNullable to only refer to the object you're returning
NonNullable<RouterOutputs['abc']['def']>['someMember']
NonNullable<RouterOutputs['abc']['def']>['someMember']
Prabhath
Prabhath2y ago
Yeah that worked type NonNullable<T> = Exclude<T, null | undefined>; // Remove null and undefined and then NonNullable<RouterOutputs['abc']['def']>['someMember']
Want results from more Discord servers?
Add your server