Evan You пре 3 година
родитељ
комит
23bd3b2ca3
4 измењених фајлова са 13 додато и 16 уклоњено
  1. 4 4
      src/core/global-api/extend.ts
  2. 1 1
      src/global.d.ts
  3. 1 1
      src/platforms/web/runtime/index.ts
  4. 7 10
      typescript/component.d.ts

+ 4 - 4
src/core/global-api/extend.ts

@@ -17,7 +17,7 @@ export function initExtend(Vue: GlobalAPI) {
   /**
    * Class inheritance
    */
-  Vue.extend = function (extendOptions: any): Component {
+  Vue.extend = function (extendOptions: any): typeof Component {
     extendOptions = extendOptions || {}
     const Super = this
     const SuperId = Super.cid
@@ -33,7 +33,7 @@ export function initExtend(Vue: GlobalAPI) {
 
     const Sub = (function VueComponent(this: any, options: any) {
       this._init(options)
-    } as unknown) as Component
+    } as unknown) as typeof Component
     Sub.prototype = Object.create(Super.prototype)
     Sub.prototype.constructor = Sub
     Sub.cid = cid++
@@ -78,14 +78,14 @@ export function initExtend(Vue: GlobalAPI) {
   }
 }
 
-function initProps(Comp: Component) {
+function initProps(Comp: typeof Component) {
   const props = Comp.options.props
   for (const key in props) {
     proxy(Comp.prototype, `_props`, key)
   }
 }
 
-function initComputed(Comp: Component) {
+function initComputed(Comp: typeof Component) {
   const computed = Comp.options.computed
   for (const key in computed) {
     defineComputed(Comp.prototype, key, computed[key])

+ 1 - 1
src/global.d.ts

@@ -34,4 +34,4 @@ interface DevtoolsHook {
   off: (event?: string, handler?: Function) => void
   Vue?: any
   // apps: AppRecordOptions[]
-}
+}

+ 1 - 1
src/platforms/web/runtime/index.ts

@@ -10,7 +10,7 @@ import {
   isReservedTag,
   isReservedAttr,
   getTagNamespace,
-  isUnknownElement,
+  isUnknownElement
 } from 'web/util/index'
 
 import { patch } from './patch'

+ 7 - 10
typescript/component.d.ts

@@ -2,6 +2,7 @@ import type VNode from '../src/core/vdom/vnode'
 import type Watcher from '../src/core/observer/watcher'
 import { ComponentOptions } from './options'
 import { ScopedSlotsData, VNodeChildren, VNodeData } from './vnode'
+import { GlobalAPI } from './global-api'
 
 // TODO this should be using the same as /component/
 
@@ -11,23 +12,19 @@ export declare class Component {
   static cid: number
   static options: Record<string, any>
   // extend
-  static extend: (options: Record<string, any>) => typeof Component
+  static extend: GlobalAPI['extend']
   static superOptions: Record<string, any>
   static extendOptions: Record<string, any>
   static sealedOptions: Record<string, any>
   static super: Component
   // assets
-  static directive: (
-    id: string,
-    def?: Function | Record<string, any>
-  ) => Function | Record<string, any> | void
-  static component: (
-    id: string,
-    def?: Component | Record<string, any>
-  ) => Component
-  static filter: (id: string, def?: Function) => Function | void
+  static directive: GlobalAPI['directive']
+  static component: GlobalAPI['component']
+  static filter: GlobalAPI['filter']
   // functional context constructor
   static FunctionalRenderContext: Function
+  static mixin: GlobalAPI['mixin']
+  static use: GlobalAPI['use']
 
   // public properties
   $el: any // so that we can attach __vue__ to it