Argument of type 'string' is not assignable to parameter of type 'DynamicReferenceBuilder<never>'.

The following statement, is giving me the error on the title
fn("round", [fn.min("ld.price_btc"), sql.lit(5)]).as("floor_price"),
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✅
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✅
5 Replies
Daniel Cruz
Daniel CruzOP2y ago
Seems to be an issue with min but I don't understand why For now I fixed it by not using Kysely's min function
fn("round", [fn("min", ["ld.price_btc"]), sql.lit(5)]).as(
"floor_price"
),
fn("round", [fn("min", ["ld.price_btc"]), sql.lit(5)]).as(
"floor_price"
),
Igal
Igal2y ago
Hey 👋🏻 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.
Daniel Cruz
Daniel CruzOP2y ago
why should it be never? 😅
Igal
Igal2y ago
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. but we still allow consumer to pass {return_type} | null optionally and 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 assertion
Daniel Cruz
Daniel CruzOP2y ago
ok ok thanks 🙂
Want results from more Discord servers?
Add your server