base.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license
  3. * Copyright 2017 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { ReactiveElement } from '../reactive-element.js';
  7. export declare type Constructor<T> = {
  8. new (...args: any[]): T;
  9. };
  10. export interface ClassDescriptor {
  11. kind: 'class';
  12. elements: ClassElement[];
  13. finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
  14. }
  15. export interface ClassElement {
  16. kind: 'field' | 'method';
  17. key: PropertyKey;
  18. placement: 'static' | 'prototype' | 'own';
  19. initializer?: Function;
  20. extras?: ClassElement[];
  21. finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
  22. descriptor?: PropertyDescriptor;
  23. }
  24. export declare const legacyPrototypeMethod: (descriptor: PropertyDescriptor, proto: Object, name: PropertyKey) => void;
  25. export declare const standardPrototypeMethod: (descriptor: PropertyDescriptor, element: ClassElement) => {
  26. kind: string;
  27. placement: string;
  28. key: PropertyKey;
  29. descriptor: PropertyDescriptor;
  30. };
  31. /**
  32. * Helper for decorating a property that is compatible with both TypeScript
  33. * and Babel decorators. The optional `finisher` can be used to perform work on
  34. * the class. The optional `descriptor` should return a PropertyDescriptor
  35. * to install for the given property.
  36. *
  37. * @param finisher {function} Optional finisher method; receives the element
  38. * constructor and property key as arguments and has no return value.
  39. * @param descriptor {function} Optional descriptor method; receives the
  40. * property key as an argument and returns a property descriptor to define for
  41. * the given property.
  42. * @returns {ClassElement|void}
  43. */
  44. export declare const decorateProperty: ({ finisher, descriptor, }: {
  45. finisher?: ((ctor: typeof ReactiveElement, property: PropertyKey) => void) | null | undefined;
  46. descriptor?: ((property: PropertyKey) => PropertyDescriptor) | undefined;
  47. }) => (protoOrDescriptor: ReactiveElement | ClassElement, name?: PropertyKey | undefined) => void | any;
  48. //# sourceMappingURL=base.d.ts.map