Decorator: a higher-order function applied with @name syntax. At runtime it receives the decorated target and can wrap, replace, or annotate it, enabling cross-cutting concerns like logging, validation, or dependency injection.
2 / 5
Which TypeScript compiler option must be enabled to use experimental decorators?
experimentalDecorators: because decorators are still evolving in the TC39 proposal process, TypeScript gates them behind this flag. Without it the compiler rejects @-prefixed syntax.
3 / 5
What arguments does a class decorator receive?
Class decorator args: it receives only the constructor (target). You can return a new class extending it, add static members, or register it in a container based on that reference.
4 / 5
What does a method decorator's PropertyDescriptor allow you to do?
Method decorator: receives (target, propertyKey, descriptor). Wrapping descriptor.value lets you intercept calls, add timing, memoize results, or enforce preconditions without touching the original code.
5 / 5
What is decorator metadata (via reflect-metadata) commonly used for?
reflect-metadata: TypeScript emits type information when emitDecoratorMetadata is enabled. Frameworks read Reflect.getMetadata('design:type', ...) to discover what to inject into constructors.