I don’t know what you need this for…
// Set up the condition in JS
%%raw(`
class Foo {
bar() {
console.log("bar called")
}
}
function getFoo() {
return Foo
}
`)
module type Foo = {
type t
}
module FooInterface = {
external getFooClass: unit => module(Foo) = "getFoo"
external make: module(Foo) => module(Foo) = "new"
@send external bar: module(Foo) => unit = "bar"
}
let foo = FooInterface.getFooClass()->FooInterface.make
foo->FooInterface.bar
A little operator priority problem here. Just use new as the name 
To add constraints from the interface you can
module FooInterface = {
type t
external getFooClass: unit => module(Foo with type t = t) = "getFoo"
external make: module(Foo with type t = t) => module(Foo with type t = t) = "new"
@send external bar: module(Foo with type t = t) => unit = "bar"
}