Hi,
Is it possible to properly define a ReScript type to bind to a TypeScript object using mapped types like:
type t = {
[key: string]: {
children: string;
};
}
Thanks
Hi,
Is it possible to properly define a ReScript type to bind to a TypeScript object using mapped types like:
type t = {
[key: string]: {
children: string;
};
}
Thanks
When the keys aren’t known statically you’d use a Dict
in ReScript:
type entry = {children: string}
type t = Dict.t<entry>
let dict: t = Dict.make()
dict->Dict.set("someKey", {children: "child"})
Compiles to:
var dict = {};
dict["someKey"] = {
children: "child"
};