At the time of publishing this article according to the TC repository decorators are still in the candidate phase stage . If you want to use decorators in TypeScript simply enable them using the configuration option experimentalDecorators. You can pass it on transpilation or add the key with the value truein the tsconfig.
Once you enable decorators you can now use them as described in the TypeScript documentation . Below you will find a practical example of a simple Handler whose handle method has been decorated with a method that logs Phone Number List the input data. function logParams return function target unknown propertyKey string sed parameters that allow obtaining information from where the decorator was called.
In the example presented targetit is an object of the class Handler is the name of the decorated method and descriptorit is an instance of the property descriptor of the method handle. Note especially that the decorator returns a function that will be called at the time of decorating. Everything above the return keyword will be called before the handle method is decorated. Take a look at the example below and see in what order each message is logged.