Constructing js options objects involving inheritance?

Hi Folks
I have a js world interop question that is maybe a matter of style and wonder how youd all handle it.
In Highcharts, charts are configured with an expansive options object, that branches out into configurations for headers, axes, series data, tooltip callbacks, data column sources etc. In many of these are polymorphic and involve inheritance. each different type of chart is configured with a different object, all extending ‘seriesOptions’ for example, with nearly all fields being optional

I have modelled this as a lot of @deriving(abstract), and then pasting the extended elements from the (hierarchy) ancestors into each one. Then I have a variety of external ... %identity to cast the specific types into the generic one for association with their (data construction) parents. This makes construction pretty clear, but is a huge maintenance burden on the bindings.

(this is my 22k file from the other thread if you were wondering where I was going with that)

How would you handle it?


Rescript Object would allow to extend the type and create a new type. will that help?

In the following example we can use the point3d type of value at all the places where point2d type of value is expected.

Point3D values can be used wherever point2d values are expected. - Object | ReScript Language Manual