Hey all,
I’m exploring ReScript/GenType and the typescript files produced for some particular use cases I have. I grabbed the rescript-project-template
from github and gave the following expression a shot:
Js.log("Hello, World!")
@genType
let seq = (~seq=?, ~key=?, x) => {
x * x
}
If I compile this with GenType, I get a tsx file produced which is great. The relevant generated code looks as follows:
export const seq: <T1,T2>(_1:{ readonly seq?: T1; readonly key?: T2 }, x:number) => number = function <T1,T2>(Arg1: any, Arg2: any) {
const result = Curry._3(DemoBS.seq, Arg1.seq, Arg1.key, Arg2);
return result
};
This is great, but I’m curious about one specific detail here. As written in rescript, it’s totally fine to omit both kwargs and just invoke seq(5)
. In the generated Typescript, it’s not, you must explicitly invoke seq({}, 5)
. I understand that rescript doesn’t have function overloading, but is it possible to configure GenType here to produce a TS overload? Where the end user could write seq(5)
and the library would implicitly forward that call to seq({}, 5)
for them?
Thanks!