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
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
You can simply do:
I get the following error when i do this
Property 'subProperty' does not exist on type '(MainProperty & { subProperty: SubProperty[]; }) | null | undefined'
Try wrapping it with NonNullable to only refer to the object you're returning
Yeah that worked
type NonNullable<T> = Exclude<T, null | undefined>; // Remove null and undefined
and then NonNullable<RouterOutputs['abc']['def']>['someMember']