I have created a tree-like structure in my implementation, consisting of parent and child objects. The parents contain a list of children while the children have references to their parents, facilitating easy navigation through the tree. I am now contemplating whether such a structure will ever be garbage collected due to the presence of strong reference cycles (as I am not aware of weak pointers in TypeScript).
Below is a basic example of this structure:
class Symbol {
protected parent: Symbol | undefined;
protected children: Symbol[];
}
What is the recommended strategy for dealing with this type of data structure? Should I consider using the newer WeakMap or WeakSet classes to reference parents (even though it may seem cumbersome)?