Skip to content

Commit af64b71

Browse files
committed
👕 refactor(flowtype): fix flow check errors [ci skip]
1 parent 5188018 commit af64b71

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

.flowconfig

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ decls
1212

1313
[options]
1414
unsafe.enable_getters_and_setters=true
15+
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe

src/components/validity/methods-event.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function (Vue: GlobalAPI): Object {
88
this.$emit(type, ...args)
99
}
1010

11-
function _interceptEvents (child: VNode, multiple: boolean): Object {
11+
function _interceptEvents (child: VNode, multiple: boolean): void {
1212
(multiple ? (child.children || []) : [child]).forEach((child: VNode) => { this._wrapEvent(child) })
1313
}
1414

@@ -66,17 +66,17 @@ export default function (Vue: GlobalAPI): Object {
6666
}
6767

6868
function getModelDirective (child: VNode): ?VNodeDirective {
69-
return (child.data.directives || []).find(dir => { return dir.name === 'model' })
69+
return ((child.data && child.data.directives ) || []).find(dir => { return dir.name === 'model' })
7070
}
7171

7272
function getEventSources (child: VNode): Object {
7373
const sources: Object = {}
7474
const listeners = sources.listeners = child.componentOptions
7575
? child.componentOptions.listeners
76-
: child.data.on
76+
: (child.data && child.data.on)
7777
sources.type =
78-
(child.tag === 'input' && child.data.attrs.type === 'text') ||
79-
child.tag.match(/vue-component/)
78+
(child.tag === 'input' && (child.data && child.data.attrs && child.data.attrs.type) === 'text') ||
79+
(child.tag && child.tag.match(/vue-component/))
8080
? 'input'
8181
: 'change'
8282
if (listeners) {

src/config.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/* @flow */
22

33
// validator configrations
4-
let validator = {
4+
let validator: ValidatorConfig = {
55
classes: {}
66
}
77

88
export default function (Vue: GlobalAPI): void {
99
// define Vue.config.validator configration
10+
// $FlowFixMe: https://github.com/facebook/flow/issues/285
1011
Object.defineProperty(Vue.config, 'validator', {
1112
enumerable: true,
1213
configurable: true,
13-
get: () => { return validator },
14-
set: val => { validator = val }
14+
get: (): ValidatorConfig => { return validator },
15+
set: (val: ValidatorConfig) => { validator = val }
1516
})
1617
}

src/elements/helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22
import { looseEqual, MODEL_NOTIFY_EVENT } from '../util'
33

4-
export function addEventInfo (e: HTMLEvents) {
4+
export function addEventInfo (e: any) {
55
e[MODEL_NOTIFY_EVENT] = 'DOM'
66
}
77

src/util.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ export function looseEqual (a: any, b: any): boolean {
2525
)
2626
}
2727

28-
export function getClass (el: HTMLElement): string {
28+
export function getClass (el: any): string {
2929
let classname: string | Object = el.className
3030
if (typeof classname === 'object') {
3131
classname = classname.baseVal || ''
3232
}
3333
return classname
3434
}
3535

36-
export function setClass (el: HTMLElement, cls: string): void {
36+
export function setClass (el: any, cls: string): void {
3737
if (isIE9 && !/svg$/.test(el.namespaceURI)) {
3838
el.className = cls
3939
} else {
4040
el.setAttribute('class', cls)
4141
}
4242
}
4343

44-
export function addClass (el: HTMLElement, cls: string): void {
44+
export function addClass (el: any, cls: string): void {
4545
if (el.classList) {
4646
el.classList.add(cls)
4747
} else {
@@ -52,7 +52,7 @@ export function addClass (el: HTMLElement, cls: string): void {
5252
}
5353
}
5454

55-
export function removeClass (el: HTMLElement, cls: string): void {
55+
export function removeClass (el: any, cls: string): void {
5656
if (el.classList) {
5757
el.classList.remove(cls)
5858
} else {
@@ -68,7 +68,7 @@ export function removeClass (el: HTMLElement, cls: string): void {
6868
}
6969
}
7070

71-
export function toggleClasses (el: HTMLElement, key: string, fn: Function): void {
71+
export function toggleClasses (el: any, key: string, fn: Function): void {
7272
if (!el) { return }
7373

7474
key = key.trim()
@@ -83,8 +83,8 @@ export function toggleClasses (el: HTMLElement, key: string, fn: Function): void
8383
}
8484
}
8585

86-
export function triggerEvent (el: HTMLElement, event: string, fn: Function): void {
87-
const e: HTMLEvents = document.createEvent('HTMLEvents')
86+
export function triggerEvent (el: any, event: string, fn: Function): void {
87+
const e: any = document.createEvent('HTMLEvents')
8888
e.initEvent(event, true, true)
8989
fn && fn(e)
9090
el.dispatchEvent(e)

0 commit comments

Comments
 (0)