Extract OrderBy TS Keys
Hey I have the following query
And I'm trying to create a function that accepts that query and adds and orderBy expression based in some conditions
How can I get the accepted
key
value types so I can put them in my type
declaration?4 Replies
@Igal sorry for the ping 😅 I think this might had lost between other posts
I was able to make it work in the following way. I'd like your input if this is a good approach or is there any helper I'm not aware of @Igal
Hey 👋
Your approach could break if
orderBy
has overloads.
You should infer DB
, TB
& O
of query.
And then StringReference<DB, TB> | keyof O
roughly:
not sure what you're gaining out of this wrapper thoI dropped the function wrapper 😅 but I still need to get the possible keys, since I want to build a type safe white list to pass to my orderBy
What do you mean by
orderBy
having overloads?kysely uses function overloads, might make
Parameters<Fn>
behave unexpectedly
or break between versions if we change overloads order, or add new overloads.