I'm using TypeScript with --module system
(SystemJS) in a very large project. SystemJS supports cyclic dependencies, and most of the time it works fine. However, when TypeScript inheritance gets involved, things begin to break.
For example, if a class A
depends on class B
, and class B
inherits from class A
, then if class A
gets loaded first:
- It will pause
class A's
resolution and will try to load theclass B
dependency class B
will think its dependencies are resolved, sinceclass A
has been touched.class B's
inheritance will fail to resolve, becauseclass A
is still undefined.
Most of the "solutions" I can find on the web to circular dependencies with module loaders are either:
- Change your design / combine classes into a single module
- CommonJS and non-TypeScript specific workarounds
I feel like there are valid justifications for circular designs, and combining classes into giant files is not always desirable, so please consider these workarounds to be off topic for the question that I am asking.
Are there any solutions to the actual problem?