Syntax Lookup

Enter some language construct you want to know more about.
This is the @return decorator.

The @return decorator is used to control how null and undefined values are converted to option types in ReScript.

Example

ReScriptJS Output
type element
type dom

@send @return(nullable)
external getElementById: (dom, string) => option<element> = "getElementById"

let test = dom => {
  let elem = dom->getElementById("haha")
  switch elem {
  | None => 1
  | Some(_) => 2
  }
}

References