component.js 4.6 KB

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