Skip to content

Commit 728c171

Browse files
committed
test: fix flow errors
1 parent fe7b8e2 commit 728c171

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

flow/options.flow.js

+19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ declare type Options = {
1818
shouldProxy?: boolean
1919
}
2020

21+
declare type NormalizedOptions = {
22+
attachToDocument?: boolean,
23+
propsData?: Object,
24+
mocks: Object,
25+
methods: { [key: string]: Function },
26+
slots?: SlotsObject,
27+
scopedSlots?: { [key: string]: string | Function },
28+
localVue?: Component,
29+
provide?: Object | Function,
30+
stubs: { [name: string]: Component | true | string },
31+
context?: Object,
32+
attrs?: { [key: string]: string },
33+
listeners?: { [key: string]: Function | Array<Function> },
34+
parentComponent?: Object,
35+
logModifiedComponents?: boolean,
36+
sync: boolean,
37+
shouldProxy?: boolean
38+
}
39+
2140
declare type SlotValue = Component | string | Array<Component | string>
2241

2342
declare type SlotsObject = { [name: string]: SlotValue }

packages/create-instance/create-instance.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function createChildren(vm, h, { slots, context }) {
4141

4242
export default function createInstance(
4343
component: Component,
44-
options: Options,
44+
options: NormalizedOptions,
4545
_Vue: Component
4646
): Component {
4747
const componentOptions = isConstructor(component)

packages/shared/merge-options.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @flow
22
import { normalizeStubs, normalizeProvide } from './normalize'
3+
import { isPlainObject } from './validators'
34

45
function getOption(option, config?: Object): any {
56
if (option === false) {
@@ -19,16 +20,27 @@ function getOption(option, config?: Object): any {
1920
}
2021
}
2122

22-
export function mergeOptions(options: Options, config: Config): Options {
23+
function getStubs(stubs, configStubs): Object {
24+
const normalizedStubs = normalizeStubs(stubs)
25+
const mergedStubs = getOption(normalizedStubs, configStubs)
26+
return isPlainObject(mergedStubs) ? mergedStubs : {}
27+
}
28+
29+
export function mergeOptions(
30+
options: Options,
31+
config: Config
32+
): NormalizedOptions {
2333
const mocks = (getOption(options.mocks, config.mocks): Object)
2434
const methods = (getOption(options.methods, config.methods): {
2535
[key: string]: Function
2636
})
2737
const provide = (getOption(options.provide, config.provide): Object)
38+
const stubs = (getStubs(options.stubs, config.stubs): Object)
39+
// $FlowIgnore We know that stubs will be an object
2840
return {
2941
...options,
3042
provide: normalizeProvide(provide),
31-
stubs: getOption(normalizeStubs(options.stubs), config.stubs),
43+
stubs,
3244
mocks,
3345
methods,
3446
sync: !!(options.sync || options.sync === undefined)

0 commit comments

Comments
 (0)