Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
3 replies
noctate

passing object as a props, how to type it

Heyy lets say I have fully typed object from a backend on a page like this
const { data: getCoin } = trpc.coin.getCoin.useQuery({ name: id });

His type looks like this
symbol: string;
    name: string;
    image: {
        large: string;
    };
    market_cap_rank: number;
    links: {
        homepage: string[];
    ...

But now I want to to pass it as prop to a component. Is there a way to not loose types? I mean it's kinda dumb to just create another schema for typescript right? Is there cool way to not loose types there?
For example
<CoinInfo getCoin={getCoin} />

and then
 export const CoinInfo = ({ getCoin }) => 
Was this page helpful?