Parameterized types with gen_js_api

Trying to create a binding for runtime.onMessage:

The following code is not accepted by gen_js_api: “Error: Cannot parse class declaration”

class ['message, 'response] listener : Ojs.t ->
        inherit Ojs.obj
        method add_listener : ('message -> message_sender -> 'response Promise.t) -> unit
        method remove_listener : ('message -> message_sender -> 'response Promise.t) -> unit
        method has_listener : ('message -> message_sender -> 'response Promise.t) -> bool

val on_message : ('message, 'response) listener
    val on_message' : (Ojs.t, Ojs.t) listener [ "browser.runtime.onMessage"]
    let on_message = Obj.magic on_message'

What is the correct way to create this binding?

1 Like