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
{{ message }}
Repository navigation
Using feTS with Prisma client code-generation, undefined vs null
#456
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
Uh oh!
There was an error while loading. Please reload this page.
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].tsBut 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].tsI think this occurs because the code-generated Prisma client API code uses
nullfor these non-mandatory fields, not 'undefined'. I think in Prismaundefinedmeans "do nothing" rather than "no value".If I hack the type to
undefinedinstead , 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?
All reactions