Reason/BuckleScript when run on a Javascript runtime also has a `Js.t` type which is basically the Javascript object. You do have to define the shape of it similar to how you'd define a record type, but you don't need to convert it into a native record. JS arrays are also natively supported - it maps 1:1 to BuckleScript's array. I like to convert arrays into lists since they are better suited for value-based programming (pattern-matching over [head, ...tail] inside recursive functions).
And if you create your types in a way that invalid states are impossible, you've just reduced the cognitive load needed to work on the system for the rest of its life by an order of magnitude. Here are some resources on this wonderful programming technique:
- https://fsharpforfunandprofit.com/posts/designing-with-types...
- https://www.youtube.com/watch?v=IcgmSRJHu_8
[@bs.deriving jsConverter]
type person = {name: string, age: int};
let bob = {name: "Bob", age: 33};
let olderBob = {...bob, age: bob.age + 1};
let () = Js.log(personToJs(olderBob));I was thinking about going from a JS library to Reason, where you basically get bags full of strings.