Return type when fields are conditional
Probably more of a TypeScript question than a Kysely question, but how would I type the output of a wrapper function that allows the conditional specification of fields. E.g.
The inferred type is {} and I'd like the return type to include the fields that were specified in the fields property?
Solution:Jump to solution
Conditional selects | Kysely
Sometimes you may want to select some fields based on a runtime condition.
3 Replies
With some help from ChatGPT 4o, I eventually got to this which works:
Solution
Conditional selects | Kysely
Sometimes you may want to select some fields based on a runtime condition.
Oh, nice. Thank you