Does anyone know of a way to achieve something similar to TypeScript intersection types in Reason? Here’s the context.
I have a [bs.deriving abstract]
with a set of known fields.
[@bs.deriving abstract]
type renderArgs('data) = {
fetching: bool,
loaded: bool,
data: 'data,
error: string
};
The user then supplies a map of mutation
s they want to make available, which I have modeled currently as a Js.Dict.t
(open to changing that). Is there any way I can intersect this Js.Dict.t
with renderArgs
to create an “intersection type” in the TypeScript sense. In TS, the definition looks like this:
declare type RendersArgs<Data, Mutations> = {
fetching: boolean;
loaded: boolean,
data: Data,
error: string
} & Mutations;
Is something like this possible with Reason / BuckleScript? Thanks for any help!