Bucklescript allows one to define raw js function calls, but it's not clear to me how the return type should be handled. It seems one can use any type and it'll still work. For example, this code compiles and runs without problems:
let f = [%raw {|
function() {
return 4;
}
|}]
let x : (string option) list = f ()
The compiler won't complain that x has type (string option) list
or any other bogus type. Normally, I'd just rely on type inference, but I want to assign the result of a raw js function call to a field in a struct, so I do have to define a type for that field in the struct type definition. It seems I can also use whatever type and it'll still work. Is that the expected behavior? Are there any recommendations to deal with these cases?