K
Join ServerKysely
help
Argument of type 'string' is not assignable to parameter of type 'DynamicReferenceBuilder<never>'.
The following statement, is giving me the error on the title
I have other
fn("round", [fn.min("ld.price_btc"), sql.lit(5)]).as("floor_price"),
I have other
fn
calls that don't fail, so Idk what could be the issue fn("round", [fn.min("ld.price_btc"), sql.lit(5)]).as("floor_price"), // TS does complain ❌
fn("round", [fn.sum("s.volume"), sql.lit(2)]).as("volume"), // TS does not complain ✅
fn("round", [fn.avg("s.avg_price"), sql.lit(5)]).as("avg_price"),// TS does not complain✅
Seems to be an issue with
min
but I don't understand whyFor now I fixed it by not using Kysely's
min
function fn("round", [fn("min", ["ld.price_btc"]), sql.lit(5)]).as(
"floor_price"
),
Hey 👋🏻
Thanks for reporting this. Will look into it tomorrow.
Thanks for reporting this. Will look into it tomorrow.
Another workaround is to
fn.min<never>("ld.price_btc")
For some odd reason, TS decides that the first generic is
any
by default while it should be never
.why should it be never? 😅
max/min are different.
they're bound by their data type, so we know the return type and can enforce it from the column reference.
they're bound by their data type, so we know the return type and can enforce it from the column reference.
but we still allow consumer to pass
{return_type} | null
optionallyand partial generics break, yadda yadda
(TS team just scheduled a fix for that btw)
anyway,
string | number | bigint | null = never
allowed checking if user didn't choose return type, with a very simple assertion. = any
requires less simple assertionok ok thanks 🙂