2. Class Decorator

# Typescript Decorator
Medium

Class decorator

Official TS Docs provide an example of a class decorator that you can look at, too. Class decorators just pass our original class into the decorator annotation to process the class or the class prototype. That's it.

Decorator Factory

The above method adds a
decorator to the
, and the properties of this decorator will override the default properties of the
. In order to conveniently add other parameters to the decorator, we transform
into a decorator factory as follows:

Other usages

We can also assign or override properties or methods on the class prototype chain
, as well as static properties and methods of the class itself. We can also overload the constructor function.