Is there a way to not have as many Selectable<> generics?
Hi. I'm using
prisma-kysely
to generate my Kysely types, and it generates them with the Generated generic. I therefore need to use the Selectable generic to change it to the return type of what is selected when I want to use the type. Is there a way to avoid using it so often?6 Replies
You can give the selectable version a shorter alias:
Or better yet, trust type inference whenever possible and don't use an explicit type.
the issue is that I can't assign the right type to function calls without using selectables, but otherwise it makes sense
thanks 👍
Could you provide an example of what you mean?
fnA will have a TS error because
actualSize
is Generated<number>
, whilst fnB and fnC will work without TS errors. kind of annoying to have to specify everything is Selectable but i guess it makes senseWell as I mentioned, you only need to do it once and then import that type. The table interfaces are not meant to be used as row types.
Instead of importing
DelegationApplication
you'd import DelegationApplicationRow
or whatever you want to call it. The DelegationApplication
should only really be used in the database "schema" type, and never anywhere else.
This is what I do:
You could open an issue in prisma-kysely
github if they'd consider exporting those by default from the generated filesounds great 👍