I am seeing the following compilation error:
TS1238: Unable to resolve signature of class decorator when called as an expression.
Here is the code:
const fdec = function(target:any, field: any, desc: any){
console.log('target 0 :', target);
target.bar = 3;
return target;
};
const fdec2 = function(){
console.log('target 1:');
return function(target:any, field: any, desc: any){
console.log('target 2:', target);
target.bar = 3;
return target;
}
};
@fdec
@fdec2()
class Foo {
static bar: number
}
console.log(Foo.bar);
console.log(new Foo());
Does anyone know how to fix that error?
The signature for a class decorator (as ou can find in lib.d.ts) has to be the following:
So your class decorator can't have a
field
anddesc
parameter (or they should be optional if you plan to use the decorator as a field decorator as well)