options.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import VNode from "../src/core/vdom/vnode";
  2. import { Component } from "./component";
  3. declare type InternalComponentOptions = {
  4. _isComponent: true;
  5. parent: Component;
  6. _parentVnode: VNode;
  7. render?: Function;
  8. staticRenderFns?: Array<Function>;
  9. };
  10. type InjectKey = string | Symbol;
  11. declare type ComponentOptions = {
  12. [key: string]: any
  13. componentId?: string;
  14. // data
  15. data: object | Function | void;
  16. props?: { [key: string]: PropOptions };
  17. propsData?: object;
  18. computed?: {
  19. [key: string]:
  20. | Function
  21. | {
  22. get?: Function;
  23. set?: Function;
  24. cache?: boolean;
  25. };
  26. };
  27. methods?: { [key: string]: Function };
  28. watch?: { [key: string]: Function | string };
  29. // DOM
  30. el?: string | Element;
  31. template?: string;
  32. render: (h: () => VNode) => VNode;
  33. renderError?: (h: () => VNode, err: Error) => VNode;
  34. staticRenderFns?: Array<() => VNode>;
  35. // lifecycle
  36. beforeCreate?: Function;
  37. created?: Function;
  38. beforeMount?: Function;
  39. mounted?: Function;
  40. beforeUpdate?: Function;
  41. updated?: Function;
  42. activated?: Function;
  43. deactivated?: Function;
  44. beforeDestroy?: Function;
  45. destroyed?: Function;
  46. errorCaptured?: () => boolean | void;
  47. serverPrefetch?: Function;
  48. // assets
  49. directives?: { [key: string]: object };
  50. components?: { [key: string]: Component };
  51. transitions?: { [key: string]: object };
  52. filters?: { [key: string]: Function };
  53. // context
  54. provide?: Record<string | symbol, any> | (() => Record<string | symbol, any>);
  55. inject?:
  56. | { [key: string]: InjectKey | { from?: InjectKey; default?: any } }
  57. | Array<string>;
  58. // component v-model customization
  59. model?: {
  60. prop?: string;
  61. event?: string;
  62. };
  63. // misc
  64. parent?: Component;
  65. mixins?: Array<object>;
  66. name?: string;
  67. extends?: Component | object;
  68. delimiters?: [string, string];
  69. comments?: boolean;
  70. inheritAttrs?: boolean;
  71. // Class API
  72. abstract?: any
  73. // private
  74. _isComponent?: true;
  75. _propKeys?: Array<string>;
  76. _parentVnode?: VNode;
  77. _parentListeners?: object | null;
  78. _renderChildren?: Array<VNode> | null;
  79. _componentTag: string | null;
  80. _scopeId: string | null;
  81. _base: Component;
  82. };
  83. declare type PropOptions = {
  84. type: Function | Array<Function> | null;
  85. default: any;
  86. required: boolean | null;
  87. validator: Function | null;
  88. };