component.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import type VNode from "../src/core/vdom/vnode";
  2. import type Watcher from "../src/core/observer/watcher";
  3. import { ComponentOptions } from "./options";
  4. import { ScopedSlotsData, VNodeChildren, VNodeData } from "./vnode";
  5. // TODO this should be using the same as /component/
  6. declare class Component {
  7. // constructor information
  8. static cid: number;
  9. static options: Record<string, any>;
  10. // extend
  11. static extend: (options: Record<string, any>) => Function;
  12. static superOptions: Record<string, any>;
  13. static extendOptions: Record<string, any>;
  14. static sealedOptions: Record<string, any>;
  15. static super: Component;
  16. // assets
  17. static directive: (
  18. id: string,
  19. def?: Function | Record<string, any>
  20. ) => Function | Record<string, any> | void;
  21. static component: (
  22. id: string,
  23. def?: Component | Record<string, any>
  24. ) => Component;
  25. static filter: (id: string, def?: Function) => Function | void;
  26. // functional context constructor
  27. static FunctionalRenderContext: Function;
  28. // public properties
  29. $el: any; // so that we can attach __vue__ to it
  30. $data: Record<string, any>;
  31. $props: Record<string, any>;
  32. $options: ComponentOptions;
  33. $parent: Component | undefined;
  34. $root: Component;
  35. $children: Array<Component>;
  36. $refs: {
  37. [key: string]: Component | Element | Array<Component | Element> | undefined;
  38. };
  39. $slots: { [key: string]: Array<VNode> };
  40. $scopedSlots: { [key: string]: () => VNodeChildren };
  41. $vnode: VNode; // the placeholder node for the component in parent's render tree
  42. $attrs: { [key: string]: string };
  43. $listeners: Record<string, Function | Array<Function>>;
  44. $isServer: boolean;
  45. // public methods
  46. $mount: (el?: Element | string, hydrating?: boolean) => Component;
  47. $forceUpdate: () => void;
  48. $destroy: () => void;
  49. $set: <T>(
  50. target: Record<string, any> | Array<T>,
  51. key: string | number,
  52. val: T
  53. ) => T;
  54. $delete: <T>(
  55. target: Record<string, any> | Array<T>,
  56. key: string | number
  57. ) => void;
  58. $watch: (
  59. expOrFn: string | Function,
  60. cb: Function,
  61. options?: Record<string, any>
  62. ) => Function;
  63. $on: (event: string | Array<string>, fn: Function) => Component;
  64. $once: (event: string, fn: Function) => Component;
  65. $off: (event?: string | Array<string>, fn?: Function) => Component;
  66. $emit: (event: string, ...args: Array<any>) => Component;
  67. $nextTick: (fn: Function) => void | Promise<any>;
  68. $createElement: (
  69. tag?: string | Component,
  70. data?: Record<string, any>,
  71. children?: VNodeChildren
  72. ) => VNode;
  73. // private properties
  74. _uid: number | string;
  75. _name: string; // this only exists in dev mode
  76. _isVue: true;
  77. _self: Component;
  78. _renderProxy: Component;
  79. _renderContext?: Component;
  80. _watcher: Watcher | null;
  81. _watchers: Array<Watcher>;
  82. _computedWatchers: { [key: string]: Watcher };
  83. _data: Record<string, any>;
  84. _props: Record<string, any>;
  85. _events: Record<string, any>;
  86. _inactive: boolean | null;
  87. _directInactive: boolean;
  88. _isMounted: boolean;
  89. _isDestroyed: boolean;
  90. _isBeingDestroyed: boolean;
  91. _vnode?: VNode | null; // self root node
  92. _staticTrees?: Array<VNode> | null; // v-once cached trees
  93. _hasHookEvent: boolean;
  94. _provided?: Record<string, any>;
  95. // _virtualComponents?: { [key: string]: Component };
  96. // private methods
  97. // lifecycle
  98. _init: Function;
  99. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  100. _update: (vnode: VNode, hydrating?: boolean) => void;
  101. // rendering
  102. _render: () => VNode;
  103. __patch__: (
  104. a: Element | VNode | void | null,
  105. b: VNode | null,
  106. hydrating?: boolean,
  107. removeOnly?: boolean,
  108. parentElm?: any,
  109. refElm?: any
  110. ) => any;
  111. // createElement
  112. // _c is internal that accepts `normalizationType` optimization hint
  113. _c: (
  114. vnode?: VNode,
  115. data?: VNodeData,
  116. children?: VNodeChildren,
  117. normalizationType?: number
  118. ) => VNode | void;
  119. // renderStatic
  120. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren;
  121. // markOnce
  122. _o: (
  123. vnode: VNode | Array<VNode>,
  124. index: number,
  125. key: string
  126. ) => VNode | VNodeChildren;
  127. // toString
  128. _s: (value: any) => string;
  129. // text to VNode
  130. _v: (value: string | number) => VNode;
  131. // toNumber
  132. _n: (value: string) => number | string;
  133. // empty vnode
  134. _e: () => VNode;
  135. // loose equal
  136. _q: (a: any, b: any) => boolean;
  137. // loose indexOf
  138. _i: (arr: Array<any>, val: any) => number;
  139. // resolveFilter
  140. _f: (id: string) => Function;
  141. // renderList
  142. _l: (val: any, render: Function) => Array<VNode> | null;
  143. // renderSlot
  144. _t: (
  145. name: string,
  146. fallback?: Array<VNode>,
  147. props?: Record<string, any>
  148. ) => Array<VNode> | null;
  149. // apply v-bind object
  150. _b: (
  151. data: any,
  152. tag: string,
  153. value: any,
  154. asProp: boolean,
  155. isSync?: boolean
  156. ) => VNodeData;
  157. // apply v-on object
  158. _g: (data: any, value: any) => VNodeData;
  159. // check custom keyCode
  160. _k: (
  161. eventKeyCode: number,
  162. key: string,
  163. builtInAlias?: number | Array<number>,
  164. eventKeyName?: string
  165. ) => boolean | null;
  166. // resolve scoped slots
  167. _u: (
  168. scopedSlots: ScopedSlotsData,
  169. res?: Record<string, any>
  170. ) => { [key: string]: Function };
  171. // SSR specific
  172. _ssrNode: Function;
  173. _ssrList: Function;
  174. _ssrEscape: Function;
  175. _ssrAttr: Function;
  176. _ssrAttrs: Function;
  177. _ssrDOMProps: Function;
  178. _ssrClass: Function;
  179. _ssrStyle: Function;
  180. // allow dynamic method registration
  181. [key: string]: any;
  182. }