February 2019
Beginner
694 pages
18h 4m
English
Method decorators are decorators that can be applied to a method on a class. Method decorators are invoked by the JavaScript runtime with three parameters. Remember that class decorators have only a single parameter (the class prototype) and property decorators have two parameters (the class prototype and the property name). Method decorators have three parameters. The class prototype, the method name, and (optionally) a method descriptor. The third parameter, the method descriptor is only populated if compiling for ES5 and above.
Let's take a look at a method decorator, as follows:
function methodDec ( target: any,
methodName: string,
descriptor?: PropertyDescriptor) { console.log(`target: ${target}`); console.log(`methodName ...Read now
Unlock full access