I'm trying to create a binding for an existing javascript library but I'm getting an error when I try to use the property access function.
[@bs.deriving abstract]
type objA = {
prop1: string,
prop2: string,
prop3: string,
};
[@bs.deriving abstract]
type objB = {
prop2: string,
prop4: string,
};
[@bs.module "myLib"] external getObjA: (unit) => objA = "";
[@bs.module "myLib"] external getObjB: (unit) => objB = "";
let obj = getObjA();
prop2Get(obj) |> Js.log
// ------^^^
// Error: This expression has type objA but an expression was expected of type objB
I know that both objects have the same property name, so the generated function prop2Get(...) is being overridden. What is the solution for this case?