In an implementation I have a tree-like structure with parent and child objects. The parents have a child list and the children a reference to their parents, in order to be able to navigate easily thru the tree. Now I wonder if such a structure would ever be garbage collected, given that we have strong reference cycles here (I'm not aware of weak pointers in TypeScript).
Here's a (dead simple) example for such a structure, though I believe everyone can imagine how that would look like:
class Symbol {
protected parent: Symbol | undefined;
protected children: Symbol[];
}
What is the recommended approach for such kind of data structure? Use the (relatively) new WeakMap or WeakSet classes to reference parents (which sounds ugly)?