【发布时间】:2018-12-03 19:24:52
【问题描述】:
我正在学习 javascript 中的装饰器。我使用打字稿进行编译 下面是代码:
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
@enumerable(false)
greet() {
return "Hello, " + this.greeting;
}
}
function enumerable(value: boolean) {
return
function(target:any,propertyKey:string,descriptor:PropertyDescriptor) {
descriptor.enumerable = value;
};
}
其实代码来自http://www.typescriptlang.org/docs/handbook/decorators.html 使用 tsc 编译文件时,出现以下错误:
first.ts:39:5 - 错误 TS1241:当作为表达式调用时,无法解析方法装饰器的签名。 39 @可枚举(假) 这个问题我该怎么办
【问题讨论】:
标签: typescript