I currently have a type in my application layer that has some option
properties. I’m using a library (Automerge) that requires that values are JSON-like, so no properties can be defined as undefined
or it throws a runtime error. I have a few options (no pun intended) about what to do here, but I’m trying to get a sense of what the most idiomatic/ergonomic solution here might be:
- Use
Js.Nullable.t
instead ofoption
in my application domain model and passnull
for the nulalble properties instead ofundefined
. - Strip the undefined keys by
stringify->parse
before passing to Automerge. - Something else I haven’t thought of?
I guess the basic question is how much of a smell is using Js.Nullable.t
“inside” of the application domain and if it’s pretty smelly, what are some common patterns to push that type closer to the JS-edge?