Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1823

Escaping the word type

$
0
0

It’ll probably be more ergonomic to use the @as annotation instead, which would let you use whatever name you wanted within rescript, e.g.:

type sourceData = {
  @as("type")
  type_: string,
  geometry: sourceDataGeometry,
}

module Source = {
  @module("react-map-gl") @react.component
  external make: (
    ~id: string,
    @as("type")
    ~type_: string,
    ~data: sourceData,
    ~children: React.element,
  ) => React.element = "Source"
}

<ReactMapGL.Source id="tenMilesTrail" type_="geojson" data={tenMilesData}>

Viewing all articles
Browse latest Browse all 1823

Trending Articles