options.d.ts 2.3 KB

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