How to properly infer type or add typings of a returned model with relationship in a component props
getCart.tsx
page.tsx
cart-summary.tsx
4 Replies
Make a standalone function
Eg. getCart
I do have that and currently I'm just using getCart also on CartSummary since it can be cached. but I wanna know how to add typings on a prop way.
I donβt know if this is useful but I use the returned db function to define the schema - it has a method called $inferSelect which gives you the select model.
you can do typeof dbTable.$inferSelect
I have tried that and it only works if no eager loaded relationship is returned on the query.