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

How to return record of specific type?

$
0
0

It’s good practice to put such record types into their own modules, then you can qualify the module where the record comes from after the opening curly brace:

e.g.:

module Opt = {
  type t = {label: string, value: string}
}

type props = {label?: string, value?: string, data: array<Opt.t>}

let make = (props: props) => {
  let opt = {Opt.label: "123", value: "abc"}
  opt
}

Viewing all articles
Browse latest Browse all 1787

Trending Articles