component.d.ts 5.2 KB

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