options.d.ts 2.3 KB

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