You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if any of my Prisma fields are not mandatory, I get Typescript errors, for example here I'll make "role" optional in the Prisma schema and in the feTS router definition.
prisma.schema:
model Person {
userId String @unique
role String?
}
I think this occurs because the code-generated Prisma client API code uses null for these non-mandatory fields, not 'undefined'. I think in Prisma undefined means "do nothing" rather than "no value".
If I hack the type to undefined instead , the Typescript error goes away. Obviously this was just hacking for this issue and is not a proper solution.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use Prisma with code-generated schema types, and I am trying to return one of those schema types via a feTS router in NextJS.
Following the documentation, I use createRouter() and add my endpoint.
If all of my Prisma types are mandatory, then everything is fine.
prisma.schema
:[...slug].ts
But if any of my Prisma fields are not mandatory, I get Typescript errors, for example here I'll make "role" optional in the Prisma schema and in the feTS router definition.
prisma.schema
:[...slug].ts
I think this occurs because the code-generated Prisma client API code uses
null
for these non-mandatory fields, not 'undefined'. I think in Prismaundefined
means "do nothing" rather than "no value".If I hack the type to
undefined
instead , the Typescript error goes away. Obviously this was just hacking for this issue and is not a proper solution.Maybe related to #402.
What can I do here to resolve this?
Beta Was this translation helpful? Give feedback.
All reactions