component.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 super: Class<Component>;
  13. // assets
  14. static directive: (id: string, def?: Function | Object) => Function | Object | void;
  15. static component: (id: string, def?: Class<Component> | Object) => Class<Component>;
  16. static filter: (id: string, def?: Function) => Function | void;
  17. // public properties
  18. $el: any; // so that we can attach __vue__ to it
  19. $data: Object;
  20. $options: ComponentOptions;
  21. $parent: Component | void;
  22. $root: Component;
  23. $children: Array<Component>;
  24. $refs: { [key: string]: Component | Element | Array<Component | Element> | void };
  25. $slots: { [key: string]: Array<VNode> };
  26. $scopedSlots: { [key: string]: () => VNodeChildren };
  27. $vnode: VNode;
  28. $isServer: boolean;
  29. $props: Object;
  30. // public methods
  31. $mount: (el?: Element | string, hydrating?: boolean) => Component;
  32. $forceUpdate: () => void;
  33. $destroy: () => void;
  34. $set: (obj: Array<mixed> | Object, key: mixed, val: mixed) => void;
  35. $delete: (obj: Object, key: string) => void;
  36. $watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function;
  37. $on: (event: string, fn: Function) => Component;
  38. $once: (event: string, fn: Function) => Component;
  39. $off: (event?: string, fn?: Function) => Component;
  40. $emit: (event: string, ...args: Array<mixed>) => Component;
  41. $nextTick: (fn: Function) => void;
  42. $createElement: (tag?: string | Component, data?: Object, children?: VNodeChildren) => VNode;
  43. // private properties
  44. _uid: number;
  45. _isVue: true;
  46. _self: Component;
  47. _renderProxy: Component;
  48. _renderContext: ?Component;
  49. _watcher: Watcher;
  50. _watchers: Array<Watcher>;
  51. _computedWatchers: { [key: string]: Watcher };
  52. _data: Object;
  53. _props: Object;
  54. _events: Object;
  55. _inactive: boolean;
  56. _isMounted: boolean;
  57. _isDestroyed: boolean;
  58. _isBeingDestroyed: boolean;
  59. _vnode: ?VNode;
  60. _staticTrees: ?Array<VNode>;
  61. _hasHookEvent: boolean;
  62. // private methods
  63. // lifecycle
  64. _init: Function;
  65. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  66. _update: (vnode: VNode, hydrating?: boolean) => void;
  67. _updateFromParent: (
  68. propsData: ?Object,
  69. listeners: ?{ [key: string]: Function | Array<Function> },
  70. parentVnode: VNode,
  71. renderChildren: ?Array<VNode>
  72. ) => void;
  73. // rendering
  74. _render: () => VNode;
  75. __patch__: (a: Element | VNode | void, b: VNode) => any;
  76. // createElement
  77. // _c is internal that accepts `normalizationType` optimization hint
  78. _c: (vnode?: VNode, data?: VNodeData, children?: VNodeChildren, normalizationType?: number) => VNode | void;
  79. // renderStatic
  80. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren;
  81. // markOnce
  82. _o: (vnode: VNode | Array<VNode>, index: number, key: string) => VNode | VNodeChildren;
  83. // toString
  84. _s: (value: mixed) => string;
  85. // text to VNode
  86. _v: (value: string | number) => VNode;
  87. // toNumber
  88. _n: (value: string) => number | string;
  89. // empty vnode
  90. _e: () => VNode;
  91. // loose equal
  92. _q: (a: mixed, b: mixed) => boolean;
  93. // loose indexOf
  94. _i: (arr: Array<mixed>, val: mixed) => number;
  95. // resolveFilter
  96. _f: (id: string) => Function;
  97. // renderList
  98. _l: (val: mixed, render: Function) => ?Array<VNode>;
  99. // renderSlot
  100. _t: (name: string, fallback: ?Array<VNode>, props: ?Object) => ?Array<VNode>;
  101. // apply v-bind object
  102. _b: (data: any, value: any, asProp?: boolean) => VNodeData;
  103. // check custom keyCode
  104. _k: (eventKeyCode: number, key: string, builtInAlias: number | Array<number> | void) => boolean;
  105. // resolve scoped slots
  106. _u: (scopedSlots: Array<[string, Function]>) => { [key: string]: Function };
  107. // allow dynamic method registration
  108. [key: string]: any
  109. }