As I dive deeper into TypeScript, I've noticed that no error is thrown when attempting to instantiate class B
inside of class A
.
class A {
public static foo = new B();
}
class B { }
If we were to call A.foo
after these definitions, it would clearly result in a failure since B does not precede A lexically. Removing the static
keyword is out of the question (as it's necessary).
Am I left with manually rearranging the class definitions as my only option? Or are there clever workarounds available to avoid this issue? Could a module loader come to my rescue, or do I still need to explicitly specify the dependency order?