我们如何在模块系统中使用继承?

时间:2014-04-24 05:29:28

标签: inheritance typescript

我有一个模块和两个类:

module OpenORPG {

    export class MovementSystem extends GameSystem {
}

}


module OpenORPG {

    export class GameSystem {

        public parent: Zone;

}

}

他们看起来像那样。这会出现错误,如本期中所述:https://typescript.codeplex.com/workitem/627

但这会发生在模块中。谁能评论如何获得这些类型的依赖?我只是害怕:

  

未捕获的TypeError:无法读取未定义的属性'prototype'

1 个答案:

答案 0 :(得分:1)

即使在模块内,您也需要正确订购两个,即

module OpenORPG {
    export class GameSystem {
        public parent: Zone;
    }
}

module OpenORPG {
    export class MovementSystem extends GameSystem {
}

更新:如果您在单独的文件中进行此拆分,则可以使用--out文件按顺序列出reference生成的代码。

PS:grunt-ts可以为您生成参考文件https://github.com/grunt-ts/grunt-ts#javascript-generation-and-ordering