I have a function that returns another function. At first I’ve written it like this:
type baz = {foo: option<bool>}
type bar = unit => baz
let make = (): bar => {
() => {
{
foo: None,
}
}
}
The make function has a type unit => bar
which is correct.
After this I had to spend a bunch of time (partially because I haven’t written tests for this part) trying to figure out why the Curry helper didn’t work properly in js output before I’ve noticed that the module’ve been transpiled into this:
function make(param, param$1) {
return {
foo: undefined
};
}
export {
make ,
}
Just a function that imediatly returns a result.
I’ve rewritten my module to this, that helped with the problem, but still it wasn’t a good experience debugging the error.
type baz = {foo: option<bool>}
type bar = unit => baz
let make = () => {
let bar: bar = () => {
{
foo: None,
}
}
bar
}
On the rescript side the make’s type in both cases was correct.