inferring types from tRPC array

I'm trying to understand how to correctly work with inferring types when using a tRPC query, when i get an array of objects.

Since i'm using prisma - i'm getting the types of the objects in the DB that i'm fetching, so my ucrrent solution is this;
type Question = RouterOutputs["question"]["getAll"][0];

But this feels like a really bad solution/ work around.

Furthermore - i'm getting the types as a prop from a different component upstream, with the current implementation.

type Question = RouterOutputs["question"]["getAll"][0]; const Word: React.FC<{ question: Question }> = (props) => { if (!props.question) return <div>no data</div>; const question = props.question; return (........


Would appreciate some guidance as to what is the best practice here
Was this page helpful?