diff --git a/flow/compiler.js b/flow/compiler.js index a5ebc5f3..81e1c6eb 100644 --- a/flow/compiler.js +++ b/flow/compiler.js @@ -173,21 +173,13 @@ declare type SFCDescriptor = { template: ?SFCBlock; script: ?SFCBlock; styles: Array; - customBlocks: Array; -} - -declare type SFCCustomBlock = { - type: string; - content: string; - start?: number; - end?: number; - src?: string; - attrs: {[attribute:string]: string}; + customBlocks: Array; }; declare type SFCBlock = { type: string; content: string; + attrs: {[attribute:string]: string}; start?: number; end?: number; lang?: string; diff --git a/package-lock.json b/package-lock.json index 3166d2e0..fe025956 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3814,9 +3814,9 @@ } }, "flow-bin": { - "version": "0.54.1", - "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.54.1.tgz", - "integrity": "sha1-cQG8zPAG3AZScUqK7wxyB4p2BRA=", + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.61.0.tgz", + "integrity": "sha512-w6SGi5CDfKLNGzYssRhW6N37qKclDXijsxDQ5M8c3WbivRYta0Horv22bwakegfKBVDnyeS0lRW3OqBC74eq2g==", "dev": true }, "flow-remove-types-no-whitespace": { diff --git a/package.json b/package.json index bd4fc173..2cda61ad 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "eslint-plugin-jasmine": "^2.8.4", "eslint-plugin-vue-libs": "^2.0.1", "file-loader": "^1.1.5", - "flow-bin": "^0.54.0", + "flow-bin": "^0.61.0", "hash-sum": "^1.0.2", "he": "^1.1.1", "http-server": "^0.10.0", diff --git a/src/compiler/create-compiler.js b/src/compiler/create-compiler.js index b6690d8a..6671dcfe 100644 --- a/src/compiler/create-compiler.js +++ b/src/compiler/create-compiler.js @@ -26,7 +26,7 @@ export function createCompilerCreator (baseCompile: Function): Function { // merge custom directives if (options.directives) { finalOptions.directives = extend( - Object.create(baseOptions.directives), + Object.create(baseOptions.directives || null), options.directives ) } diff --git a/src/compiler/to-function.js b/src/compiler/to-function.js index d9f20056..7fe0f13f 100644 --- a/src/compiler/to-function.js +++ b/src/compiler/to-function.js @@ -18,9 +18,7 @@ function createFunction (code, errors) { } export function createCompileToFunctionFn (compile: Function): Function { - const cache: { - [key: string]: CompiledFunctionResult; - } = Object.create(null) + const cache = Object.create(null) return function compileToFunctions ( template: string, diff --git a/src/core/config.js b/src/core/config.js index 18fc3d94..f25f09d1 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -36,6 +36,7 @@ export default ({ /** * Option merge strategies (used in core/util/options) */ + // $flow-disable-line optionMergeStrategies: Object.create(null), /** @@ -76,6 +77,7 @@ export default ({ /** * Custom user key aliases for v-on */ + // $flow-disable-line keyCodes: Object.create(null), /** diff --git a/src/core/instance/lifecycle.js b/src/core/instance/lifecycle.js index 9280de9a..46b931e0 100644 --- a/src/core/instance/lifecycle.js +++ b/src/core/instance/lifecycle.js @@ -212,7 +212,7 @@ export function updateChildComponent ( vm: Component, propsData: ?Object, listeners: ?Object, - parentVnode: VNode, + parentVnode: MountedComponentVNode, renderChildren: ?Array ) { if (process.env.NODE_ENV !== 'production') { diff --git a/src/core/instance/render-helpers/resolve-slots.js b/src/core/instance/render-helpers/resolve-slots.js index 0065e3c9..02f007cf 100644 --- a/src/core/instance/render-helpers/resolve-slots.js +++ b/src/core/instance/render-helpers/resolve-slots.js @@ -1,5 +1,7 @@ /* @flow */ +import type VNode from 'core/vdom/vnode' + /** * Runtime helper for resolving raw children VNodes into a slot object. */ @@ -23,10 +25,10 @@ export function resolveSlots ( if ((child.context === context || child.fnContext === context) && data && data.slot != null ) { - const name = child.data.slot + const name = data.slot const slot = (slots[name] || (slots[name] = [])) if (child.tag === 'template') { - slot.push.apply(slot, child.children) + slot.push.apply(slot, child.children || []) } else { slot.push(child) } diff --git a/src/core/instance/state.js b/src/core/instance/state.js index 4fa6f15b..72d9edd8 100644 --- a/src/core/instance/state.js +++ b/src/core/instance/state.js @@ -161,6 +161,7 @@ function getData (data: Function, vm: Component): any { const computedWatcherOptions = { lazy: true } function initComputed (vm: Component, computed: Object) { + // $flow-disable-line const watchers = vm._computedWatchers = Object.create(null) // computed properties are just getters during SSR const isSSR = isServerRendering() diff --git a/src/core/vdom/modules/directives.js b/src/core/vdom/modules/directives.js index 42e33f9e..639982fa 100644 --- a/src/core/vdom/modules/directives.js +++ b/src/core/vdom/modules/directives.js @@ -86,17 +86,20 @@ function normalizeDirectives ( ): { [key: string]: VNodeDirective } { const res = Object.create(null) if (!dirs) { + // $flow-disable-line return res } let i, dir for (i = 0; i < dirs.length; i++) { dir = dirs[i] if (!dir.modifiers) { + // $flow-disable-line dir.modifiers = emptyModifiers } res[getRawDirName(dir)] = dir dir.def = resolveAsset(vm.$options, 'directives', dir.name, true) } + // $flow-disable-line return res } diff --git a/src/platforms/web/util/class.js b/src/platforms/web/util/class.js index 1da7ef23..542dcbc4 100644 --- a/src/platforms/web/util/class.js +++ b/src/platforms/web/util/class.js @@ -2,18 +2,18 @@ import { isDef, isObject } from 'shared/util' -export function genClassForVnode (vnode: VNode): string { +export function genClassForVnode (vnode: VNodeWithData): string { let data = vnode.data let parentNode = vnode let childNode = vnode while (isDef(childNode.componentInstance)) { childNode = childNode.componentInstance._vnode - if (childNode.data) { + if (childNode && childNode.data) { data = mergeClassData(childNode.data, data) } } while (isDef(parentNode = parentNode.parent)) { - if (parentNode.data) { + if (parentNode && parentNode.data) { data = mergeClassData(data, parentNode.data) } } diff --git a/src/platforms/web/util/style.js b/src/platforms/web/util/style.js index 7b066373..fc119043 100644 --- a/src/platforms/web/util/style.js +++ b/src/platforms/web/util/style.js @@ -40,7 +40,7 @@ export function normalizeStyleBinding (bindingStyle: any): ?Object { * parent component style should be after child's * so that parent component's style could override it */ -export function getStyle (vnode: VNode, checkChild: boolean): Object { +export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object { const res = {} let styleData @@ -48,7 +48,10 @@ export function getStyle (vnode: VNode, checkChild: boolean): Object { let childNode = vnode while (childNode.componentInstance) { childNode = childNode.componentInstance._vnode - if (childNode.data && (styleData = normalizeStyleData(childNode.data))) { + if ( + childNode && childNode.data && + (styleData = normalizeStyleData(childNode.data)) + ) { extend(res, styleData) } } diff --git a/src/sfc/parser.js b/src/sfc/parser.js index 56221809..868a43ca 100644 --- a/src/sfc/parser.js +++ b/src/sfc/parser.js @@ -27,7 +27,7 @@ export function parseComponent ( customBlocks: [] } let depth = 0 - let currentBlock: ?(SFCBlock | SFCCustomBlock) = null + let currentBlock: ?SFCBlock = null function start ( tag: string, @@ -44,7 +44,7 @@ export function parseComponent ( attrs: attrs.reduce((cumulated, { name, value }) => { cumulated[name] = value || true return cumulated - }, Object.create(null)) + }, {}) } if (isSpecialTag(tag)) { checkAttrs(currentBlock, attrs) @@ -95,7 +95,7 @@ export function parseComponent ( depth-- } - function padContent (block: SFCBlock | SFCCustomBlock, pad: true | "line" | "space") { + function padContent (block: SFCBlock, pad: true | "line" | "space") { if (pad === 'space') { return content.slice(0, block.start).replace(replaceRE, ' ') } else {