【发布时间】:2014-01-27 20:43:33
【问题描述】:
我正在尝试在我的网站的打字稿中设置一些“模块”,但我得到了相互矛盾的信息和相互矛盾的结果。例如,我有三个“类”。 Prototype、Item 和 Tag。他们三个都需要有一组特定的属性,所以我决定将其作为基类ComponentModel,如下所示。
module website.admin.components {
export class ComponentModel {
public Components = { // define property };
}
}
现在,我想在我的其他三个中继承这个类,所以我从'tags'开始。
module website.admin.viewModels {
export class Tag extends website.admin.components.ComponentModel {
// tag specific properties
constructor() { super(); } // initialize the base class as required
}
}
好的,这似乎可行。但是Prototype 类上完全相同的代码不起作用;
module website.admin.viewModels {
export class Prototype extends website.admin.components.ComponentModel {
// prototype specific properties
constructor() { super(); }
}
}
这只会导致各种奇怪的行为,并且在运行时拒绝工作。我收到以下错误;
未捕获的类型错误:无法读取未定义的属性“组件模型”
未捕获的类型错误:无法读取未定义的属性“原型”
Uncaught TypeError: undefined is not a function
谁能帮我弄清楚为什么会这样?我能做些什么来阻止它?越来越烦人了。
【问题讨论】:
标签: typescript