jackJ
tRPC4y ago
12 replies
jack

type mismatch between tRPC return (in sveltekit) and defined type

i've got this piece of code:
read: async () => {
  const res = await trpc($page).getCards.query();

  if (!res) return;

  cards = cards_reducer(cards, {
    type: 'reload',
    payload: { cards: res }
  });
},

the issue is that the type of res, as returned from trpc, is
SerializeObject<UndefinedToOptional<Card & { tasks: Task[]; }>>[]
, while i've type my cards state as
(Card & { tasks: Task[]; })[];
. as far as i can tell, there should be no mismatch in type here, but the linter isn't happy with trying to pass
res
as the same type as
cards
Was this page helpful?