@xxx("xxx")
class A{
msg:string
constructor(msg:string) {
this.msg = msg
}
print() {
console.log(this.msg)
}
}
function xxx(arg:string) {
function f(target) {
function ff(msg: string) {
return new target(arg + ":" + msg)
}
return ff
}
return f
}
let a = new A("hellow")
a.print()
编译时,它会报告:
decorator.ts(1,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. Type '(msg: string) => any' is not assignable to type 'void'.
但是genrated js执行得很好.我不知道为什么报告错误.