Improving TS compile speed with multiple conditional selects?
Hi, I have API endpoints that query Postgres via Kysely. The API endpoints accept an
include
object that determines whether to include various optional fields. Some endpoints have grown to accept 5-10 optional fields.
Each of these optional fields results in an additional $if
branch in the Kysely query. And this seems to harm TS compile speed -- I'm now waiting 1-3min for each compilation.
What are the best ways to mitigate the compile speed downsides of using many $if
calls?4 Replies
(I should add that some of these optional fields use
jsonObjectFrom
and I'm aware of https://github.com/kysely-org/kysely/issues/867)GitHub
Issues · kysely-org/kysely
A type-safe typescript SQL query builder. Contribute to kysely-org/kysely development by creating an account on GitHub.
Hey 👋
$assertType
might help.
https://search.app?link=https%3A%2F%2Fkysely.dev%2Fdocs%2Frecipes%2Fexcessively-deep-types&utm_campaign=aga&utm_source=agsadl2%2Csh%2Fx%2Fgs%2Fm2%2F4
Also, perhaps replacing many $if
s into single $call
s.Dealing with the Type instantiation is excessively deep and possibl...
Kysely uses complex type magic to achieve its type safety. This complexity is sometimes
Thanks, will try that over the coming weeks
How would one replace many
$if
with a single $call
? Is there a toy example of that somewhere?Something like this:
https://kyse.link/Ij5JL