options.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { Vue } from "./vue.d";
  2. import { VNode, VNodeDirective } from "./vnode.d";
  3. type Constructor = {
  4. new (...args: any[]): any;
  5. }
  6. export interface ComponentOptions {
  7. data?: Object | ( (this: Vue) => Object );
  8. props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
  9. propsData?: Object;
  10. computed?: { [key: string]: ((this: Vue) => any) | ComputedOptions };
  11. methods?: { [key: string]: Function };
  12. watch?: { [key: string]: ({ handler: WatchHandler } & WatchOptions) | WatchHandler | string };
  13. el?: Element | String;
  14. template?: string;
  15. render?(createElement: typeof Vue.prototype.$createElement): VNode;
  16. staticRenderFns?: (() => VNode)[];
  17. beforeCreate?(): void;
  18. created?(): void;
  19. beforeDestroy?(): void;
  20. destroyed?(): void;
  21. beforeMount?(): void;
  22. mounted?(): void;
  23. beforeUpdate?(): void;
  24. updated?(): void;
  25. directives?: { [key: string]: DirectiveOptions | DirectiveFunction };
  26. components?: { [key: string]: ComponentOptions | typeof Vue };
  27. transitions?: { [key: string]: Object };
  28. filters?: { [key: string]: Function };
  29. parent?: Vue;
  30. mixins?: (ComponentOptions | typeof Vue)[];
  31. name?: string;
  32. extends?: ComponentOptions | typeof Vue;
  33. delimiters?: [string, string];
  34. }
  35. export interface PropOptions {
  36. type?: Constructor | Constructor[] | null;
  37. required?: boolean;
  38. default?: any;
  39. validator?(value: any): boolean;
  40. }
  41. export interface ComputedOptions {
  42. get?(this: Vue): any;
  43. set?(this: Vue, value: any): void;
  44. cache?: boolean;
  45. }
  46. export type WatchHandler = <T>(val: T, oldVal: T) => void;
  47. export interface WatchOptions {
  48. deep?: boolean;
  49. immediate?: boolean;
  50. }
  51. export type DirectiveFunction = (
  52. el: HTMLElement,
  53. binding: VNodeDirective,
  54. vnode: VNode,
  55. oldVnode: VNode
  56. ) => void;
  57. export interface DirectiveOptions {
  58. bind?: DirectiveFunction;
  59. update?: DirectiveFunction;
  60. componentUpdated?: DirectiveFunction;
  61. unbind?: DirectiveFunction;
  62. }