TypeScript supports class, method, accessor, property, and parameter decorators. Execution order is bottom-to-top (outer to inner): parameter decorators run first, then method decorators, then class decorators. When multiple decorators stack on a method, they compose right-to-left like function composition.
Parameter decorators run before method decorators on the same member.
Multiple decorators on the same target: factories evaluated top-to-bottom, then applied bottom-to-top.
Member decorators (methods, properties) run before class decorators.
Class decorator is always the last to execute — it sees the fully-decorated class.
In a NestJS controller, you need to log the execution time of a route handler. Which decorator would you create and how would you apply it?
If you place a @UseGuards() decorator above a @Controller() class and also above a specific method, which one runs first and why?
You added a custom @Roles() method decorator to a route, but the guard isn’t receiving the roles metadata. Walk me through how decorator execution order could cause this and how you’d fix it.
During a refactor, you moved a @Transactional() method decorator to a base class. The transaction no longer starts. Explain what might have changed in the decorator order and how to debug it.
Our microservice uses many custom class and method decorators for validation, logging, and tracing. How would you structure their order to avoid performance penalties and ensure correct metadata propagation?
We observed that applying multiple property decorators on a DTO sometimes results in missing validation rules at runtime. Discuss the execution order of property decorators and how you’d design a solution to guarantee all validators run.
We are planning to migrate a large legacy NestJS codebase to a new shared decorator library that enforces company‑wide policies. What architectural considerations and ordering strategies would you adopt to minimize breaking changes across teams?
Imagine you need to introduce a global request‑id decorator that must run before any logging or authentication decorators across all services. How would you enforce this order at the framework level and what trade‑offs does it entail?