Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Interface

PropertyDescriptor

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.

How it works

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.

Syntax

function LogMethod(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor)

Parameters

NameTypeDescription
targetanyThe object or class prototype containing the decorated member; the page's example types this as any.
propertyKeystring | symbolThe decorated property's name, represented as a string or symbol.
descriptorPropertyDescriptorThe runtime descriptor for the decorated property or method.

Key points

  • A method-decorator-style function can receive a PropertyDescriptor as its third parameter.
  • The descriptor is a runtime value that can be inspected inside the decorator function.
  • The official page presents PropertyDescriptor in the context of decorator metadata configuration.

Common mistakes

  • The documented decorator example belongs to experimental decorator metadata support; using metadata-related behavior may require the reflect-metadata module.

Example: Passing a method descriptor

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.

When to use it

Method decorators

Inspect a decorated class method's runtime metadata.

Decorator callbacks

Pass a member descriptor into decorator logic.

Decorator metadata workflows

View emitted decorator-related metadata in generated JavaScript.

  • decorators
  • emitDecoratorMetadata
  • reflect-metadata
  • propertyKey

Source: TSConfig Option: emitDecoratorMetadata. Checked 2026-10-15.