component.js 4.8 KB

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