I cannot get inheritance to work with CommonJS modules generated with typescript 1.0 ( tsc is done with --module commonjs )
This fails if two classes that inherit the same base class call each other "through" the base class.
It seems that the first class imports the base class, which imports the second class, which also imports the base class, but the last import of the base class does not work.
The following is an example illustrating this behavior.
Is there anything in the typescript or CommonJS specs that prevent me from doing this, or is this a bug?
=== Example ===
This exciting piece of software does not work by running Lower.test.ts . What he is just trying to achieve is to load a word in Lower , which stores it in lower case, and then using the inherited toUpper() method from the Base class, converts it to upper case using the Upper class (which also inherits Base )
Lower.test.ts
import Lower = require('./Lower') console.log(new Lower('smallcaps').toUpper())
Base.ts
import Upper = require('./Upper') class Base { word: string toUpper(): string { return new Upper(this.word).word } } export = Base
Upper.ts
import Base = require('./Base') class Upper extends Base { constructor(word:string) { super() this.word = word.toUpperCase() } } export = Upper
Lower.ts
import Base = require('./Base') class Lower extends Base { constructor(word:string) { super() this.word = word.toLowerCase() } } export = Lower
inheritance commonjs typescript
Bruno Grieder Jul 07 '14 at 17:55 2014-07-07 17:55
source share