Parameter Decorators
A parameter decorator is a decorator function that is applied to a single parameter of a function call. Just like property decorators, parameter decorators are passive, that is, they can be used only to observe values, but not to inject and execute code. The return value of a parameter decorator is similarly ignored. As a consequence, parameter decorators are almost exclusively used in conjunction with other, active decorators.
When a parameter decorator is called, it receives three parameters: target
, propertyKey
, and parameterIndex
:
target
: The behavior for this parameter is identical to the decorators on the corresponding method. There is an exception if the parameter is on a class' constructor, but that is explained shortly.propertyKey
: This is the name of the method whose parameter you're decorating (the constructor exception is explained shortly).parameterIndex
: This is the ordinal index of the parameter in the function...