fix(runtime-core): default value for function type prop (#1349)

fix #1348
This commit is contained in:
tangjinzhou
2020-06-12 21:06:28 +08:00
committed by GitHub
parent 4c4f39b6ea
commit d437a0145d
2 changed files with 12 additions and 2 deletions

View File

@@ -270,13 +270,16 @@ function resolvePropValue(
key: string,
value: unknown
) {
const opt = options[key]
const opt = options[key] as any
if (opt != null) {
const hasDefault = hasOwn(opt, 'default')
// default values
if (hasDefault && value === undefined) {
const defaultValue = opt.default
value = isFunction(defaultValue) ? defaultValue() : defaultValue
value =
opt.type !== Function && isFunction(defaultValue)
? defaultValue()
: defaultValue
}
// boolean casting
if (opt[BooleanFlags.shouldCast]) {