0
的ClassDecorator
被定义为:类装饰类型不匹配错误
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
我都写过这样的:
export function ClassDecorator(params: any): ClassDecorator {
return function (target) {
Object.seal(target);
Object.seal(target.prototype);
}
}
但是,编译器给我一个错误:
Error:(2, 12) TS2322:Type '(target: any, key: any, descriptor: any) => void' is not assignable to type 'ClassDecorator'.
为什么?
谢谢,一旦我修复,我得到另一个错误:'错误:(4,22)TS2339:属性'原型'不存在类型'对象'。' –
@it应该工作,如果你说目标是'任何',它看起来像你在代码中隐含的。你说它应该是'Object'类型吗? – Alex
它应该是'Function'或'TFunction'类型,据我所知,类型定义 –