Skip to content

Commit 531371b

Browse files
committed
types: upgrade flow
1 parent 4e00688 commit 531371b

File tree

13 files changed

+30
-29
lines changed

13 files changed

+30
-29
lines changed

Diff for: flow/compiler.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,13 @@ declare type SFCDescriptor = {
173173
template: ?SFCBlock;
174174
script: ?SFCBlock;
175175
styles: Array<SFCBlock>;
176-
customBlocks: Array<SFCCustomBlock>;
177-
}
178-
179-
declare type SFCCustomBlock = {
180-
type: string;
181-
content: string;
182-
start?: number;
183-
end?: number;
184-
src?: string;
185-
attrs: {[attribute:string]: string};
176+
customBlocks: Array<SFCBlock>;
186177
};
187178

188179
declare type SFCBlock = {
189180
type: string;
190181
content: string;
182+
attrs: {[attribute:string]: string};
191183
start?: number;
192184
end?: number;
193185
lang?: string;

Diff for: package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"eslint-plugin-jasmine": "^2.8.4",
8686
"eslint-plugin-vue-libs": "^2.0.1",
8787
"file-loader": "^1.1.5",
88-
"flow-bin": "^0.54.0",
88+
"flow-bin": "^0.61.0",
8989
"hash-sum": "^1.0.2",
9090
"he": "^1.1.1",
9191
"http-server": "^0.10.0",

Diff for: src/compiler/create-compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function createCompilerCreator (baseCompile: Function): Function {
2626
// merge custom directives
2727
if (options.directives) {
2828
finalOptions.directives = extend(
29-
Object.create(baseOptions.directives),
29+
Object.create(baseOptions.directives || null),
3030
options.directives
3131
)
3232
}

Diff for: src/compiler/to-function.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ function createFunction (code, errors) {
1818
}
1919

2020
export function createCompileToFunctionFn (compile: Function): Function {
21-
const cache: {
22-
[key: string]: CompiledFunctionResult;
23-
} = Object.create(null)
21+
const cache = Object.create(null)
2422

2523
return function compileToFunctions (
2624
template: string,

Diff for: src/core/config.js

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default ({
3636
/**
3737
* Option merge strategies (used in core/util/options)
3838
*/
39+
// $flow-disable-line
3940
optionMergeStrategies: Object.create(null),
4041

4142
/**
@@ -76,6 +77,7 @@ export default ({
7677
/**
7778
* Custom user key aliases for v-on
7879
*/
80+
// $flow-disable-line
7981
keyCodes: Object.create(null),
8082

8183
/**

Diff for: src/core/instance/lifecycle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export function updateChildComponent (
212212
vm: Component,
213213
propsData: ?Object,
214214
listeners: ?Object,
215-
parentVnode: VNode,
215+
parentVnode: MountedComponentVNode,
216216
renderChildren: ?Array<VNode>
217217
) {
218218
if (process.env.NODE_ENV !== 'production') {

Diff for: src/core/instance/render-helpers/resolve-slots.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* @flow */
22

3+
import type VNode from 'core/vdom/vnode'
4+
35
/**
46
* Runtime helper for resolving raw children VNodes into a slot object.
57
*/
@@ -23,10 +25,10 @@ export function resolveSlots (
2325
if ((child.context === context || child.fnContext === context) &&
2426
data && data.slot != null
2527
) {
26-
const name = child.data.slot
28+
const name = data.slot
2729
const slot = (slots[name] || (slots[name] = []))
2830
if (child.tag === 'template') {
29-
slot.push.apply(slot, child.children)
31+
slot.push.apply(slot, child.children || [])
3032
} else {
3133
slot.push(child)
3234
}

Diff for: src/core/instance/state.js

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function getData (data: Function, vm: Component): any {
161161
const computedWatcherOptions = { lazy: true }
162162

163163
function initComputed (vm: Component, computed: Object) {
164+
// $flow-disable-line
164165
const watchers = vm._computedWatchers = Object.create(null)
165166
// computed properties are just getters during SSR
166167
const isSSR = isServerRendering()

Diff for: src/core/vdom/modules/directives.js

+3
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,20 @@ function normalizeDirectives (
8686
): { [key: string]: VNodeDirective } {
8787
const res = Object.create(null)
8888
if (!dirs) {
89+
// $flow-disable-line
8990
return res
9091
}
9192
let i, dir
9293
for (i = 0; i < dirs.length; i++) {
9394
dir = dirs[i]
9495
if (!dir.modifiers) {
96+
// $flow-disable-line
9597
dir.modifiers = emptyModifiers
9698
}
9799
res[getRawDirName(dir)] = dir
98100
dir.def = resolveAsset(vm.$options, 'directives', dir.name, true)
99101
}
102+
// $flow-disable-line
100103
return res
101104
}
102105

Diff for: src/platforms/web/util/class.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
import { isDef, isObject } from 'shared/util'
44

5-
export function genClassForVnode (vnode: VNode): string {
5+
export function genClassForVnode (vnode: VNodeWithData): string {
66
let data = vnode.data
77
let parentNode = vnode
88
let childNode = vnode
99
while (isDef(childNode.componentInstance)) {
1010
childNode = childNode.componentInstance._vnode
11-
if (childNode.data) {
11+
if (childNode && childNode.data) {
1212
data = mergeClassData(childNode.data, data)
1313
}
1414
}
1515
while (isDef(parentNode = parentNode.parent)) {
16-
if (parentNode.data) {
16+
if (parentNode && parentNode.data) {
1717
data = mergeClassData(data, parentNode.data)
1818
}
1919
}

Diff for: src/platforms/web/util/style.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,18 @@ export function normalizeStyleBinding (bindingStyle: any): ?Object {
4040
* parent component style should be after child's
4141
* so that parent component's style could override it
4242
*/
43-
export function getStyle (vnode: VNode, checkChild: boolean): Object {
43+
export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object {
4444
const res = {}
4545
let styleData
4646

4747
if (checkChild) {
4848
let childNode = vnode
4949
while (childNode.componentInstance) {
5050
childNode = childNode.componentInstance._vnode
51-
if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
51+
if (
52+
childNode && childNode.data &&
53+
(styleData = normalizeStyleData(childNode.data))
54+
) {
5255
extend(res, styleData)
5356
}
5457
}

Diff for: src/sfc/parser.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function parseComponent (
2727
customBlocks: []
2828
}
2929
let depth = 0
30-
let currentBlock: ?(SFCBlock | SFCCustomBlock) = null
30+
let currentBlock: ?SFCBlock = null
3131

3232
function start (
3333
tag: string,
@@ -44,7 +44,7 @@ export function parseComponent (
4444
attrs: attrs.reduce((cumulated, { name, value }) => {
4545
cumulated[name] = value || true
4646
return cumulated
47-
}, Object.create(null))
47+
}, {})
4848
}
4949
if (isSpecialTag(tag)) {
5050
checkAttrs(currentBlock, attrs)
@@ -95,7 +95,7 @@ export function parseComponent (
9595
depth--
9696
}
9797

98-
function padContent (block: SFCBlock | SFCCustomBlock, pad: true | "line" | "space") {
98+
function padContent (block: SFCBlock, pad: true | "line" | "space") {
9999
if (pad === 'space') {
100100
return content.slice(0, block.start).replace(replaceRE, ' ')
101101
} else {

0 commit comments

Comments
 (0)