Skip to content

Commit 228f0f8

Browse files
committed
remove unnecessary :any castings due to improved flow checks
1 parent 3b426ef commit 228f0f8

File tree

14 files changed

+36
-33
lines changed

14 files changed

+36
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"eslint-plugin-jasmine": "^2.1.0",
7878
"eslint-plugin-vue": "^2.0.0",
7979
"file-loader": "^0.10.1",
80-
"flow-bin": "^0.39.0",
80+
"flow-bin": "^0.45.0",
8181
"hash-sum": "^1.0.2",
8282
"he": "^1.1.0",
8383
"http-server": "^0.9.0",

src/core/instance/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
warn,
55
nextTick,
66
toNumber,
7-
_toString,
7+
toString,
88
looseEqual,
99
emptyObject,
1010
handleError,
@@ -109,7 +109,7 @@ export function renderMixin (Vue: Class<Component>) {
109109
// code size.
110110
Vue.prototype._o = markOnce
111111
Vue.prototype._n = toNumber
112-
Vue.prototype._s = _toString
112+
Vue.prototype._s = toString
113113
Vue.prototype._l = renderList
114114
Vue.prototype._t = renderSlot
115115
Vue.prototype._q = looseEqual

src/core/vdom/create-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const componentVNodeHooks = {
9696
const hooksToMerge = Object.keys(componentVNodeHooks)
9797

9898
export function createComponent (
99-
Ctor: any,
99+
Ctor: Class<Component> | Function | Object | void,
100100
data?: VNodeData,
101101
context: Component,
102102
children: ?Array<VNode>,

src/core/vdom/create-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function applyNS (vnode, ns) {
113113
// use default namespace inside foreignObject
114114
return
115115
}
116-
if (Array.isArray(vnode.children)) {
116+
if (isDef(vnode.children)) {
117117
for (let i = 0, l = vnode.children.length; i < l; i++) {
118118
const child = vnode.children[i]
119119
if (isDef(child.tag) && isUndef(child.ns)) {

src/core/vdom/create-functional-component.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export function createFunctionalComponent (
2121
const props = {}
2222
const propOptions = Ctor.options.props
2323
if (isDef(propOptions)) {
24-
propsData = propsData || {}
2524
for (const key in propOptions) {
26-
props[key] = validateProp(key, propOptions, propsData)
25+
props[key] = validateProp(key, propOptions, propsData || {})
2726
}
2827
} else {
2928
if (isDef(data.attrs)) mergeProps(props, data.attrs)

src/core/vdom/helpers/extract-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function extractPropsFromVNodeData (
5151

5252
function checkProp (
5353
res: Object,
54-
hash: any,
54+
hash: ?Object,
5555
key: string,
5656
altKey: string,
5757
preserve: boolean

src/core/vdom/helpers/normalize-children.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
4848
res.push.apply(res, normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`))
4949
} else if (isPrimitive(c)) {
5050
if (isDef(last) && isDef(last.text)) {
51-
(last: any).text += String(c)
51+
last.text += String(c)
5252
} else if (c !== '') {
5353
// convert primitive to vnode
5454
res.push(createTextVNode(c))
@@ -59,7 +59,7 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
5959
} else {
6060
// default key for nested array children (likely generated by v-for)
6161
if (isDef(c.tag) && isUndef(c.key) && isDef(nestedIndex)) {
62-
c.key = `__vlist${(nestedIndex: any)}_${i}__`
62+
c.key = `__vlist${nestedIndex}_${i}__`
6363
}
6464
res.push(c)
6565
}

src/platforms/web/runtime/modules/dom-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
3535
// non-string values will be stringified
3636
elm._value = cur
3737
// avoid resetting cursor position when value is the same
38-
const strCur = cur == null ? '' : String(cur)
38+
const strCur = isUndef(cur) ? '' : String(cur)
3939
if (shouldUpdateValue(elm, vnode, strCur)) {
4040
elm.value = strCur
4141
}

src/platforms/web/runtime/modules/transition.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
5757
afterAppear,
5858
appearCancelled,
5959
duration
60-
} = (data: any)
60+
} = data
6161

6262
// activeInstance will always be the <transition> component managing this
6363
// transition. One edge case to check is when the <transition> is placed
@@ -201,7 +201,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
201201
leaveCancelled,
202202
delayLeave,
203203
duration
204-
} = (data: any)
204+
} = data
205205

206206
const expectsCSS = css !== false && !isIE9
207207
const userWantsControl = getHookArgumentsLength(leave)
@@ -212,7 +212,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
212212
: duration
213213
)
214214

215-
if (process.env.NODE_ENV !== 'production' && explicitLeaveDuration != null) {
215+
if (process.env.NODE_ENV !== 'production' && isDef(explicitLeaveDuration)) {
216216
checkDuration(explicitLeaveDuration, 'leave', vnode)
217217
}
218218

@@ -249,7 +249,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
249249
}
250250
// record leaving element
251251
if (!vnode.data.show) {
252-
(el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode
252+
(el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key: any)] = vnode
253253
}
254254
beforeLeave && beforeLeave(el)
255255
if (expectsCSS) {

src/platforms/web/server/modules/attrs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function renderAttrs (node: VNodeWithData): string {
1717
let attrs = node.data.attrs
1818
let res = ''
1919

20-
let parent: any = node.parent
20+
let parent = node.parent
2121
while (isDef(parent)) {
2222
if (isDef(parent.data) && isDef(parent.data.attrs)) {
2323
attrs = Object.assign({}, attrs, parent.data.attrs)

0 commit comments

Comments
 (0)