TaylorFay
TaylorFay12mo ago

trpc output dates are typed as strings and not dates

I'm using superjson as a transformer. When I query my data, it shows that fields that should be dates are typed as strings. How can I get them to be typed as dates?
6 Replies
Nick
Nick12mo ago
Have you set it up on both the server and the client?
TaylorFay
TaylorFayOP12mo ago
Yes. client
const [trpcClient] = React.useState(() =>
trpc.createClient({
transformer: superjson,
links: [
httpLink({
url: absoluteUrl('/api/trpc')
})
]
})
);
const [trpcClient] = React.useState(() =>
trpc.createClient({
transformer: superjson,
links: [
httpLink({
url: absoluteUrl('/api/trpc')
})
]
})
);
server
const t = initTRPC.context<typeof createContext>().create({
transformer: superjson
});
const t = initTRPC.context<typeof createContext>().create({
transformer: superjson
});
If it helps, I have a Next13 app using the app router. I don't believe @trpc/next works on the app router, so I'm using '@trpc/react-query'
Nick
Nick12mo ago
Well that should be enough, though not sure if there are any weirdnesses in AppRouter or NextJS as I'm not a big user of those Make sure you've restarted your language server
DINO
DINO11mo ago
I have the same problem using electron-trpc
Swaroop
Swaroop11mo ago
I tried superjson transformer recently with the App router Next.js. It worked for me. Giving a reproducible repo will help much to solve this issue.
DINO
DINO10mo ago
Yes I have solved it with superjson