I ran into a problem when trying to bind a Javascript class instance to a Rescript Record. I managed to get it working with getters and setters no problem. In the documentation, the getters and setters are said to be an “alternative” to other binding options (with my preference being to bind to a record). I was wondering if there are specific use cases when you have to use them rather than binding to a record?
Extra Thought:
When diving into the compiled JS the problem seemed to be the Curry._1. If I, for example, tried to bind to this record:
type math = {
add: (int,int)=>int
}
The output of using math.add(2,5)
it would give me this.
var x = Curry._1(Math, add(2,5))
But it would fail. However, if I change the output to this:
var x = Math.add(2,5)
everything works. Are those two expressions not equivalent?
But of course, when using getters and setters to bind, Rescript compiles to the second version. I’d love to understand what’s happening in the background so that I don’t run into this issue again!