I am currently working on representing a tree-like data structure using immutable js and typescript. At the moment, I am utilizing regular vanilla js objects to depict the nodes within the tree. Below is the type signature.
type NodeType = {
value: string
children: List<NodeType>
}
My goal is to convert this into a Record, but I am unsure of the process to achieve this. If I simply do the following:
const defaultValues: NodeType= {
value: "foo",
children: List()
}
const NodeRecord = Record(defaultValues)
...it will work fine at the top level, but it will anticipate the children to be of type NodeType
rather than RecordOf(NodeType)
.
If anyone has insight on how to accomplish this, please share. Thank you