下面的代码组件:角2:拥有多一个依赖
...
@Component({
selector: 'sitelink',
properties: ['route: route, title: title, isHome: home, href: href']
})
@View({
template: ''
})
export class SiteLink {
constructor(@Optional() @Host() @SkipSelf() parentFrame: AppFrame, @Optional() @Host() @SkipSelf() parentLink: SiteLink) {
}
...
给我下面的错误从打字稿为JavaScript
at line 32, file app-frame.ts Argument of type 'typeof SiteLink' is not assignable to parameter of type 'Type'.
Component({
selector: 'sitelink',
properties: ['route: route, title: title, isHome: home, href: href']
})
at line 36, file app-frame.ts Argument of type 'typeof SiteLink' is not assignable to parameter of type 'Type'.
View({
template: ''
})
在翻译过程中只使用一个构造函数的参数按预期工作。从参数列表中删除注释时,它也不起作用。删除@Component
和@View
注释后,代码将被编译。所以错误必须与@Component
注释相关。 编辑:即使我用另一种类型(例如AppFrame)替换SiteLink参数,我也会得到相同的错误。
我使用的是来自DefinitelyTyped存储库的alpha 36和最新的d.ts文件。
我不确定你想要做什么是可能的。在“SiteLink”的构造函数中,你正在调用这个类本身。你确定是你想要的吗? –
是的,我想获得父级“SiteLink”组件。 – derjasper
错误可能与此[问题]相同(https://github.com/angular/angular/issues/3972)。你使用什么版本的打字稿? –