Can typescript external modules have circular dependencies? -


it looks not allowed. requirejs throwing error on following (this post different resolved internal modules):

element.ts:

import runproperties = require('./run-properties'); export class element {    public static factory (element : ielement) : element {          switch (element.type) {             case type.run_properties :                 return new runproperties.runproperties().deserialize(<runproperties.irunproperties>element);         }         return null;     } } 

run-properties.ts:

import element = require('./element');  export class runproperties extends element.element implements irunproperties { } 

no, modules can't have circular dependencies unless in same file. each file being processed in sequence, synchronously, full file definition (including of exports example) hasn't been completed when goes second file, tries require/reference first file, , on.

normally, can break circular dependency introducing interface or base class common definition file(s) (basically interfaces only) , having other files use common "interface" rather directly referencing classes. typical pattern in many platforms.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -