Method decorators
Inspect a decorated class method's runtime metadata.
TypeScript · Interface
PropertyDescriptor is the descriptor parameter used in TypeScript's documented method-decorator example. It represents runtime metadata for the decorated member and is passed after the target and property key.
PropertyDescriptor is a JavaScript runtime descriptor object used in decorator-style code to describe a property or method. TypeScript documentation shows it as the descriptor parameter received alongside the target and property key in a method decorator example.
function LogMethod(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor)| Name | Type | Description |
|---|---|---|
target | any | The object or class prototype containing the decorated member; the page's example types this as any. |
propertyKey | string | symbol | The decorated property's name, represented as a string or symbol. |
descriptor | PropertyDescriptor | The runtime descriptor for the decorated property or method. |
function LogMethod(target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) {
console.log(target, propertyKey, descriptor);
}
class Demo {
foo(bar: number) {}
}
const descriptor = Object.getOwnPropertyDescriptor(Demo.prototype, "foo");
if (descriptor) LogMethod(Demo.prototype, "foo", descriptor);The example passes a method's runtime property descriptor to a decorator-style function.
Inspect a decorated class method's runtime metadata.
Pass a member descriptor into decorator logic.
View emitted decorator-related metadata in generated JavaScript.
decoratorsemitDecoratorMetadatareflect-metadatapropertyKey