diff --git a/.eslintrc b/.eslintrc index 81d1af35..726bf23d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,10 @@ { "root": true, "parser": "babel-eslint", - "extends": "vue" + "extends": "vue", + "plugins": ["flow-vars"], + "rules": { + "flow-vars/define-flow-type": 1, + "flow-vars/use-flow-type": 1 + } } diff --git a/package.json b/package.json index 59005241..87943c60 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "entities": "1.1.x", "eslint": "2.9.x", "eslint-config-vue": "1.0.x", + "eslint-plugin-flow-vars": "^0.4.0", "flow-bin": "^0.24.2", "http-server": "0.9.x", "isparta-loader": "2.0.x", diff --git a/src/entries/web-runtime-with-compiler.js b/src/entries/web-runtime-with-compiler.js index f963a702..3cc33dd2 100644 --- a/src/entries/web-runtime-with-compiler.js +++ b/src/entries/web-runtime-with-compiler.js @@ -1,3 +1,5 @@ +/* @flow */ + import config from 'core/config' import { warn, cached } from 'core/util/index' import { query } from 'web/util/index' @@ -7,7 +9,7 @@ import { compileToFunctions } from './web-compiler' const idToTemplate = cached(id => query(id).innerHTML) const mount = Vue.prototype.$mount -Vue.prototype.$mount = function (el) { +Vue.prototype.$mount = function (el?: string | Element): Vue { el = el && query(el) const options = this.$options // resolve template/el and convert to render function @@ -42,11 +44,8 @@ Vue.prototype.$mount = function (el) { /** * Get outerHTML of elements, taking care * of SVG elements in IE as well. - * - * @param {Element} el - * @return {String} */ -function getOuterHTML (el) { +function getOuterHTML (el: Element): string { if (el.outerHTML) { return el.outerHTML } else { diff --git a/src/entries/web-runtime.js b/src/entries/web-runtime.js index 3cc5c503..232467b8 100644 --- a/src/entries/web-runtime.js +++ b/src/entries/web-runtime.js @@ -1,3 +1,5 @@ +/* @flow */ + import Vue from 'core/index' import config from 'core/config' import { createPatchFunction } from 'core/vdom/patch' @@ -22,7 +24,7 @@ Vue.prototype.__patch__ = config._isServer : createPatchFunction({ nodeOps, modules }) // wrap mount -Vue.prototype.$mount = function (el) { +Vue.prototype.$mount = function (el?: string | Element): Vue { this.$el = el && query(el) return this._mount() } diff --git a/src/entries/web-server-renderer.js b/src/entries/web-server-renderer.js index 4c43f112..b369cc90 100644 --- a/src/entries/web-server-renderer.js +++ b/src/entries/web-server-renderer.js @@ -1,9 +1,14 @@ +/* @flow */ + import { createRenderer } from 'server/create-renderer' import { isUnaryTag } from 'web/util/index' import modules from 'web/server/modules/index' import baseDirectives from 'web/server/directives/index' -export default function publicCreateRenderer (options = {}) { +export default function publicCreateRenderer (options?: Object = {}): { + renderToString: Function, + renderToStream: Function +} { // user can provide server-side implementations for custom directives // when creating the renderer. const directives = Object.assign(baseDirectives, options.directives)