Open andenacitelli opened 1 year ago
Probably a bit late, but we had the same problem. We solved it by using superjson
as transformer in trpc:
import { initTRPC } from '@trpc/server';
import superjson from 'superjson';
import type { Context } from './context';
const t = initTRPC.context<Context>().create({ transformer: superjson });
// ...
I am attempting to use the generated
TaskUncheckedCreateInputSchema
schema in order to validate a type on my frontend. However, the value that comes out of this is potentially leaving my Dates (thestart
andend
fields) as strings.Relevant Frontend Bits (React + Mantine):
The
value={form.values.start}
is giving me the following TypeScript error:My suspicion is that this has to do with the
.coerce()
that zod parses dates through, but I'm not quite sure what the recommended approach to dealing with this is outside of type assertions and other escape hatches.Prisma Model
EDIT: Adding the following parses before my render code fixes things. Doesn't feel like a solid fix for me, as now it's just a fatal error rather than undefined behavior, but hopefully helps diagnose what's going on.
Love the work you've done - so much that I actually started sponsoring you on GitHub! This project saves me a bunch of boilerplate when it comes to tRPC handlers for simple (and even slightly complicated) CRUD handlers.