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

Dddanielcruzz5/4/2023
The following statement, is giving me the error on the title
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✅
Dddanielcruzz5/4/2023
Seems to be an issue with min but I don't understand why
Dddanielcruzz5/4/2023
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"
        ),
IIgal5/4/2023
Hey 👋🏻

Thanks for reporting this. Will look into it tomorrow.
IIgal5/6/2023
Another workaround is to fn.min<never>("ld.price_btc")
IIgal5/6/2023
For some odd reason, TS decides that the first generic is any by default while it should be never.
Dddanielcruzz5/7/2023
why should it be never? 😅
IIgal5/7/2023
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.
IIgal5/7/2023
but we still allow consumer to pass {return_type} | null optionally
IIgal5/7/2023
and partial generics break, yadda yadda
IIgal5/7/2023
(TS team just scheduled a fix for that btw)
IIgal5/7/2023
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
Dddanielcruzz5/8/2023
ok ok thanks 🙂