"A decorator is a function that participates when a class element is defined or initialized, wrapping behavior without hiding the underlying contract."
A value and a context object
In the current decorators model, a decorator receives the value being decorated and a context object. A method decorator receives the original method plus a ClassMethodDecoratorContext containing the element's name, kind, static and private status, and access helpers.
The decorator may return a replacement value or return nothing. A replacement method can add logging or timing while preserving the original call. Returning undefined leaves the original method in place. These hooks are installed according to class definition and initialization semantics, not improvised at each call site.
What can be decorated
The TC39 Stage 3 model covers classes, methods, getters, setters, fields, and auto-accessors. Accessors are supported: getters and setters are decorated as individual elements, while an accessor declaration uses the auto-accessor decorator shape.
Parameter decorators are not part of this model. You may still encounter them in TypeScript's legacy experimentalDecorators ecosystem, but that is a different contract from the decorator behavior TypeScript 5.0 supports without the flag.
Do not mix the legacy and current contracts
experimentalDecorators implements the calling convention of an older proposal. The current model passes a value and context object and is not compatible with emitDecoratorMetadata or parameter decorators. Check which model a library requires before choosing compiler settings or reusing a decorator function.
New code should prefer the current model, but a framework that depends on legacy metadata needs a deliberate migration. The arguments, return values, and supported capabilities differ enough that an existing decorator is not automatically portable.
The initializer hook is addInitializer
A context object's addInitializer method registers work for the appropriate class or instance initialization point. It can, for example, bind a decorated method to each instance. Use the actual context type for the decorated element instead of relying on obsolete hook names.