It seems that when you target ES3, method decorators are not supported properly or not supported at all. Unfortunately, the error message you get is not very useful. There seems to be a discussion in the error message. In addition, itβs not clear to me whether they plan partial support for decorators targeting ES3 or full support.
For example, if you try to use an ES3-oriented method decorator:
function myMethodDecorator(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> { // do something return descriptor; }; class MyClass { @myMethodDecorator myMethod(arg: string) { return "Message -- " + arg; } }
You will receive the error message that you reported:
error TS1241: Unable to resolve method decorator signature when invoked as expression. The supplied parameters do not match the signature of the target call.
But if you try to apply a property descriptor even though you apply it to a method, the compiler is strangely alright with that. This compiles ES3 targeting without errors:
function myPropertyDecorator(target: Object, propertyKey: string): void {
However, you can force it to compile ES3 when using method decorators:
let myMethodDecorator: any = function(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> { // do something return descriptor; }; class MyClass { @myMethodDecorator myMethod(arg: string) { return "Message -- " + arg; } }
source share