下面的代码
import {Attribute, Component, View} from 'angular2/angular2';
@Component({
selector: 'card'
})
@View({
templateUrl: "app/design/card/card.html",
styleUrls: ["app/design/card/card.css"],
directives: []
})
export class Card {
constructor(@Attribute('no-teaser') noTeaser) {
this.active=false
}
}
给我错误
Unable to resolve signature of parameter decorator when called as an expression. Supplied parameters do not match any signature of call target.
@Attribute('home')
将 TypeScript 转换为 JavaScript 时。
我正在使用 Alpha 37,DefinitelyTyped 的最新定义,我正在使用 atom-typescript(它使用最新的 typescript 版本)
最佳答案
Unable to resolve signature of parameter decorator when called as an expression. Supplied parameters do not match any signature of call target.
谷歌搜索这个错误:https://github.com/Microsoft/TypeScript/issues/3661
从中你可以看到:
装饰函数形式参数目前不是 ES7 提案的一部分。
所以我怀疑 constructor(@Attribute('no-teaser') noTeaser)
在最新 TypeScript 中是故意不允许的(给出 ntypescript
去 https://github.com/TypeStrong/ntypescript )。如果是这种情况,请将问题报告给 Microsoft/TypeScript。
Is it possible to tell atom-typescript which version of tsc to use?
不容易,因为旧版本的 TSC 可能与最新的 API 不兼容 ...但是有这个选项:https://github.com/TypeStrong/atom-typescript/blob/master/docs/faq.md#can-i-use-a-custom-typescript-compiler
关于javascript - Angular 2 属性注释不编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32538316/