There is another side effect of using the typedtree is that you’re not exaclty being compliant to the OCaml memory model, so you cannot hack things using Obj.magic and expect to work. Which means not supporting a couple of libraries and it mostly implies in a fork from the ecossystem like what ReScript did.
That’s why I tried to type the bytecode, without using the typings from OCaml typing the bytecode, the types from OCaml were used only to choose what representation was preferred, but the idea was to support both, encoding records as arrays and objects in JS, if a function expecting an object was called with an array I added a fallback(getter and setter), and if it’s in the same compilation unit I could in theory generate a specialized version. And that should only happens when Obj is used, so the performance should be quite stable
The problem is that I have almost zero knowledge of type theory and a simple HM seems to not be enough but I may be wrong, also I didn’t had enough time for it. Well now I’m learning about formal verification and type theory, so maybe I can try it in the future again