7. Create A Decorator
# Typescript Decorator
Medium
There are many ways to overload methods through decorators, you can choose according to your own preferences. The following are a few examples.
With Extends
Usually used to add attributes or methods in class decorators, for example:
With Prototype
Usually used to overload constructors and add properties or methods on class decorators, for example:
With Assignment
Generally used to modify a descriptor on a method decorator, for example:
With ES6 Spread Operator
Similar to the assignment method, but using the ES6+ spread syntax, it is easier to understand and use, for example: