A friend stumped me. He’s using a Javascript library that has some sort of strategy pattern where a function returns a class depending on (I dunno what
). I can’t find any way (other than using %%raw to make a saner API) to stick an @new on a class that is returned by another function.
Example JS code:
class Foo {
bar() {
console.log("bar called")
}
}
function getFoo() {
// returns a class, how silly
return Foo
}
// how to model this is rescript?
new (getFoo())().bar()
I don’t want to admit that %%raw is the only solution here.
Any thoughts?
For completeness, here is a link to the %%raw solution.