December 2017
Beginner
372 pages
10h 32m
English
As with the class decorator, the method decorator is used to annotate methods and provide additional functionality. The following is the syntax of a method decorator:
function writable(target: Object, propertyKey: string, descriptor: PropertyDescriptor) { console.log(`Setting ${propertyKey}.`); descriptor.writable = true; }
A method decorator takes three parameters, unlike the class decorator which takes only one. The first parameter in a method decorator is the same as that of the class decorator, a reference to the constructor function if the method is static or a class prototype for the instance member. The second parameter is the name of the method that would be decorated. The third parameter is the property descriptor ...
Read now
Unlock full access