I want to write a function which accepts a generic JavaScript object and makes a simple check: does the incoming object have a string-type property called “key”? If so → behavior A, else → behavior B. Making this property check convinces ReScript’s type system that the incoming object must have a particular shape, which breaks the compilation if trying to call into the function with an object that does not meet that shape. But the point is that the function is actually not expecting an object of any particular shape, it will check for what it needs and act accordingly. How do I express that?
An aside, but I think it’s worth mentioning that one can always utilise %raw (or simply a utility function in JS/TS to which you create an external). It’s perhaps especially useful in scenarios similar to this