react-hot-toast bindings for ReScript

type options = {
  className?: string,
  duration?: int,
  removeDelay?: int,
  style?: ReactDOM.Style.t,
}

/** See https://react-hot-toast.com/docs/toast */
module Toast = {
  type id = string

  type options = {
    ...options,
    id?: string,
  }

  let forever: int = Float.Constants.positiveInfinity->Obj.magic

  @module("react-hot-toast")
  external make: (string, ~options: options=?) => id = "default"

  @module("react-hot-toast") @scope("default")
  external success: (string, ~options: options=?) => id = "success"

  @module("react-hot-toast") @scope("default")
  external error: (string, ~options: options=?) => id = "error"

  @module("react-hot-toast") @scope("default")
  external loading: (string, ~options: options=?) => id = "loading"

  @module("react-hot-toast") @scope("default")
  external custom: (React.element, ~options: options=?) => id = "custom"

  @unboxed
  type promiseMessagesSuccess<'a> = String(string) | Fn('a => string)
  type promiseMessagesError = String(string) | Fn(exn => string)
  type promiseMessages<'a> = {
    loading: string,
    success?: promiseMessagesSuccess<'a>,
    error?: promiseMessagesError,
  }

  @module("react-hot-toast") @scope("default")
  external promise: (promise<'a>, ~messages: promiseMessages<'a>, ~options: options=?) => id =
    "promise"

  @module("react-hot-toast") @scope("default")
  external promiseLazy: (
    unit => promise<'a>,
    ~messages: promiseMessages<'a>,
    ~options: options=?,
  ) => id = "promise"

  @module("react-hot-toast") @scope("default")
  external dismiss: id => unit = "dismiss"

  @module("react-hot-toast") @scope("default")
  external dismissAll: unit => unit = "dismiss"

  @module("react-hot-toast") @scope("default")
  external remove: id => unit = "remove"

  @module("react-hot-toast") @scope("default")
  external removeAll: unit => unit = "remove"
}

/** See https://react-hot-toast.com/docs/toaster */
module Toaster = {
  type position =
    | @as("top-left") TopLeft
    | @as("top-center") TopCenter
    | @as("top-right") TopRight
    | @as("bottom-left") BottomLeft
    | @as("bottom-center") BottomCenter
    | @as("bottom-right") BottomRight

  type toastOptions = {
    ...options,
    success?: options,
    error?: options,
    loading?: options,
    custom?: options,
  }

  @module("react-hot-toast") @react.component
  external make: (
    ~position: position=?,
    ~reverseOrder: bool=?,
    ~containerClassName: string=?,
    ~containerStyle: ReactDOM.Style.t=?,
    ~gutter: int=?,
    ~toastOptions: options=?,
  ) => React.element = "Toaster"
}