We have {"key": value} syntax sugar for creating JavaScript-objects. With records we have syntax to immutably update a record:
let meNextYear = {...me, age: me.age + 1};
For JavaScript interop it would be great to have similar syntax for objects, something like:
let meNextYear = {...me, "age": me##age + 1};
This because it's not possible to have a single function to update an object due to the typesystem. And Js.Obj.assign loses type information (see below).
I am not sure if this is something very hard as it might need modification pretty deep inside of the (ocaml) compiler. But it would be great to have a good solution for this, JS-objects are still used in many libraries even if you don't interop with existing JavaScript code.
We have
{"key": value}
syntax sugar for creating JavaScript-objects. With records we have syntax to immutably update a record:For JavaScript interop it would be great to have similar syntax for objects, something like:
This because it's not possible to have a single function to update an object due to the typesystem. And
Js.Obj.assign
loses type information (see below).I am not sure if this is something very hard as it might need modification pretty deep inside of the (ocaml) compiler. But it would be great to have a good solution for this, JS-objects are still used in many libraries even if you don't interop with existing JavaScript code.