add a custom TypeScript decorator in a function
Not to a raw function. The main issue is dealing with hoisting of functions. Any attempt to wrap a function in another function breaks the hoist.
Support Targets
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use the form
@expression, whereexpressionmust evaluate to a function that will be called at runtime with information about the decorated declaration.
Docs: https://www.typescriptlang.org/docs/handbook/decorators.html#decorators