tRPCttRPC
Powered by
jackJ
tRPC•4y 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 }
  });
},
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[]; }>>[]
SerializeObject<UndefinedToOptional<Card & { tasks: Task[]; }>>[]
, while i've type my cards state as
(Card & { tasks: Task[]; })[];
(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
res
as the same type as
cards
cards
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Type mismatch with queryClient prop of @trpc/react-query
MadyanMMadyan / ❓-help
15mo ago
Error with AppRouter type mismatch in Deno
WeldawadyathinkWWeldawadyathink / ❓-help
17mo ago