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

How to return record of specific type?

$
0
0

I have a react element that has:

type opt = {label:string, value:string}
type props = { label?: string, value?: string, data: array<opt>}

because rescript figures out the type from the record fields when i want to provide the options it thinks im passing an array of props instead of opts.

i solved it doing:

{
let opt: MyElement.opt = {......}
opt
}

the question is is there a way of returning a record of a specific type without creating a variable and then returning it?

i tried MyElement.opt {…} but it does not work


Viewing all articles
Browse latest Browse all 1759

Trending Articles