Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
5 replies
jix74

Single element type of inferred router output array type

I'm trying to type a single object from an array but I don't want to manually create it.
I've been using inferRouterOutputs so I was wondering if it's possible to remove the [] from the type so that it is just an object.

type RouterOutput = inferRouterOutputs<AppRouter>;
type AllItemsOutput = RouterOutput["items"]["getAllItems"];


With AlItemsOutput being:
type AllItemsOutput = {
    name: string | null;
    id: string;
    description: string | null;
}[] | undefined



But I would like to convert it to:
type AllItemsOutput = {
    name: string | null;
    id: string;
    description: string | null;
} | undefined
Was this page helpful?