9.2 Property descriptors

A property descriptor encodes the attributes of a property as a JavaScript object. Their TypeScript interfaces look as follows.

  1. interface DataPropertyDescriptor {
  2. value?: any;
  3. writable?: boolean;
  4. configurable?: boolean;
  5. enumerable?: boolean;
  6. }
  7. interface AccessorPropertyDescriptor {
  8. get?: (this: any) => any;
  9. set?: (this: any, v: any) => void;
  10. configurable?: boolean;
  11. enumerable?: boolean;
  12. }
  13. type PropertyDescriptor = DataPropertyDescriptor | AccessorPropertyDescriptor;

The question marks indicate that all properties are optional. §9.7 “Omitting descriptor properties” describes what happens if they are omitted.