下面的代碼組件:角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)。你使用什麼版本的打字稿? –