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

Record creation with function

$
0
0

Hey, I discovered that the @obj directive was deprecated, due to the improvements on record creation in the new version of Rescript. But I was a big fan of having a “factory” for my custom types, not only to generate JS interop dictionaries, but to have a function, which is a better documented way of generating data for my models. eg:

I found this:

@obj
type person { name: string, email: string }

let myPerson = person(~name="john", ~email="bla@blaa.com")

better than this:

@obj
type person { name: string, email: string }

let myPerson = {name: "john", email: "bla@bla.com"}

Am I the only one who misses this functionality?


Viewing all articles
Browse latest Browse all 2592

Trending Articles