Prechádzať zdrojové kódy

annotate global api

Evan You 10 rokov pred
rodič
commit
1a65dc880f

+ 7 - 6
src/core/global-api/assets.js

@@ -1,15 +1,16 @@
+/*
+ * not type checking this file because flow doesn't like dynamically setting
+ * fields on a class
+ */
+
 import config from '../config'
 import { warn, isPlainObject } from '../util/index'
 
 export function initAssetRegisters (Vue) {
   /**
-   * Create asset registration methods with the following
-   * signature:
-   *
-   * @param {String} id
-   * @param {*} definition
+   * Create asset registration methods.
    */
-  config._assetTypes.forEach(function (type) {
+  config._assetTypes.forEach(type => {
     Vue[type] = function (id, definition) {
       if (!definition) {
         return this.options[type + 's'][id]

+ 5 - 4
src/core/global-api/extend.js

@@ -1,7 +1,10 @@
+/* @flow */
+
+import type Vue from '../instance/index'
 import config from '../config'
 import { warn, mergeOptions } from '../util/index'
 
-export function initExtend (Vue) {
+export function initExtend (Vue: Class<Vue>) {
   /**
    * Each instance constructor, including Vue, has a unique
    * cid. This enables us to create wrapped "child
@@ -12,10 +15,8 @@ export function initExtend (Vue) {
 
   /**
    * Class inheritance
-   *
-   * @param {Object} extendOptions
    */
-  Vue.extend = function (extendOptions) {
+  Vue.extend = function (extendOptions: Object): Class<any> {
     extendOptions = extendOptions || {}
     const Super = this
     const isFirstExtend = Super.cid === 0

+ 4 - 1
src/core/global-api/index.js

@@ -1,3 +1,6 @@
+/* @flow */
+
+import type Vue from '../instance/index'
 import config from '../config'
 import * as util from '../util/index'
 import { initUse } from './use'
@@ -6,7 +9,7 @@ import { initExtend } from './extend'
 import { initAssetRegisters } from './assets'
 import { set, del } from '../observer/index'
 
-export function initGlobalAPI (Vue) {
+export function initGlobalAPI (Vue: Class<Vue>) {
   Vue.config = config
   Vue.util = util
   Vue.set = set

+ 5 - 2
src/core/global-api/mixin.js

@@ -1,7 +1,10 @@
+/* @flow */
+
+import type Vue from '../instance/index'
 import { mergeOptions } from '../util/index'
 
-export function initMixin (Vue) {
-  Vue.mixin = function (mixin) {
+export function initMixin (Vue: Class<Vue>) {
+  Vue.mixin = function (mixin: Object) {
     Vue.options = mergeOptions(Vue.options, mixin)
   }
 }

+ 5 - 7
src/core/global-api/use.js

@@ -1,12 +1,10 @@
+/* @flow */
+
+import type Vue from '../instance/index'
 import { toArray } from '../util/index'
 
-export function initUse (Vue) {
-  /**
-   * Plugin system
-   *
-   * @param {Object} plugin
-   */
-  Vue.use = function (plugin) {
+export function initUse (Vue: Class<Vue>) {
+  Vue.use = function (plugin: Function | Object) {
     /* istanbul ignore if */
     if (plugin.installed) {
       return

+ 2 - 2
src/core/instance/index.js

@@ -26,12 +26,12 @@ export default class Vue {
   static nextTick: (fn: Function, context?: Object) => void;
   static use: (plugin: Function | Object) => void;
   static mixin: (mixin: Object) => void;
-  static extend: (options: Object) => Class<Vue>;
+  static extend: (options: Object) => Class<any>;
   static compile: (template: string) => { render: Function, staticRenderFns: Array<Function> };
 
   // assets
   static directive: (id: string, def?: Function | Object) => Function | Object | void;
-  static component: (id: string, def?: Class<Vue> | Object) => Class<Vue>;
+  static component: (id: string, def?: Class<any> | Object) => Class<any>;
   static transition: (id: string, def?: Object) => Object | void;
   static filter: (id: string, def?: Function) => Function | void;