component.js 4.0 KB

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