Hi Agent Coop! Glad to see you’re interested in ReScript
There are multiple ways to bind to JS types and modules.
The “traditional” way is to make the JS type an abstract type and use @send
to bind to methods of this type and @get
to bind to its properties (that’s the decorator you were missing in this case):
type viewTransition
@get external viewTransitionFinished: viewTransition => promise<unit> = "viewTransitionFinished"
@get external viewTransitionReady: viewTransition => promise<unit> = "viewTransitionReady"
@get external viewTransitionUpdateCallbackDone: viewTransition => promise<unit> = "viewTransitionUpdateCallbackDone"
@send external skipTransition: (viewTransition, unit) => unit = "skipTransition"
The other way is to make use of the uncurried mode and directly write methods and properties as fields of a record, as you’ve done:
type viewTransition = {
viewTransitionFinished: promise<unit>,
viewTransitionReady: promise<unit>,
viewTransitionUpdateCallbackDone: promise<unit>,
skipTransition: unit => unit,
}
This, though, has the drawback of only allowing one way to bind to a given property or method. It might be more suitable for simple types that have mostly imperative methods (methods that return unit).
It might be the case here.