I'm trying to implement a Typescript method decorator as follows.
function dataMethod(name: string, options: any) {
return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => {
}
}
And its used as below.
class HelloWidgetExtesion {
@dataMethod("getData", {})
public getData(name: any, cb: any) {
cb(null, "");
}
}
But I'm trying to figure out how to use decorators with Arrow function implementation as below.
class HelloWidgetExtesion {
@dataMethod("getData", {})
public getData = (name: any, cb: any) => {
cb(null, "Greetings from Loopback!");
}
}
But the above implementation shows the following error when compiling.
error TS2322: Type '(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'.