mirror of https://github.com/vuejs/core.git
Merge 70d4af0c0d
into ba391f5fdf
This commit is contained in:
commit
b7d2467311
|
@ -517,7 +517,9 @@ export default /*@__PURE__*/_defineComponent({
|
||||||
qux: { type: Function, required: false, default() { return 1 } },
|
qux: { type: Function, required: false, default() { return 1 } },
|
||||||
quux: { type: Function, required: false, default() { } },
|
quux: { type: Function, required: false, default() { } },
|
||||||
quuxx: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } },
|
quuxx: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } },
|
||||||
fred: { type: String, required: false, get default() { return 'fred' } }
|
fred: { type: String, required: false, get default() { return 'fred' } },
|
||||||
|
toLowerCase: { type: Function, required: true, default: (str: string) => str.toLowerCase() },
|
||||||
|
toUpperCase: { type: Function, required: true, default(str: string) { return str.toUpperCase() } }
|
||||||
},
|
},
|
||||||
setup(__props: any, { expose: __expose }) {
|
setup(__props: any, { expose: __expose }) {
|
||||||
__expose();
|
__expose();
|
||||||
|
|
|
@ -388,12 +388,16 @@ const props = defineProps({ foo: String })
|
||||||
quux?(): void
|
quux?(): void
|
||||||
quuxx?: Promise<string>;
|
quuxx?: Promise<string>;
|
||||||
fred?: string
|
fred?: string
|
||||||
|
toLowerCase: (str: string) => string
|
||||||
|
toUpperCase: (str: string) => string
|
||||||
}>(), {
|
}>(), {
|
||||||
foo: 'hi',
|
foo: 'hi',
|
||||||
qux() { return 1 },
|
qux() { return 1 },
|
||||||
['quux']() { },
|
['quux']() { },
|
||||||
async quuxx() { return await Promise.resolve('hi') },
|
async quuxx() { return await Promise.resolve('hi') },
|
||||||
get fred() { return 'fred' }
|
get fred() { return 'fred' },
|
||||||
|
toLowerCase: (str: string) => str.toLowerCase(),
|
||||||
|
toUpperCase(str: string){ return str.toUpperCase() }
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
`)
|
`)
|
||||||
|
@ -415,6 +419,12 @@ const props = defineProps({ foo: String })
|
||||||
expect(content).toMatch(
|
expect(content).toMatch(
|
||||||
`fred: { type: String, required: false, get default() { return 'fred' } }`,
|
`fred: { type: String, required: false, get default() { return 'fred' } }`,
|
||||||
)
|
)
|
||||||
|
expect(content).toMatch(
|
||||||
|
`toLowerCase: { type: Function, required: true, default: (str: string) => str.toLowerCase() }`,
|
||||||
|
)
|
||||||
|
expect(content).toMatch(
|
||||||
|
`toUpperCase: { type: Function, required: true, default(str: string) { return str.toUpperCase() } }`,
|
||||||
|
)
|
||||||
expect(content).toMatch(`const props = __props`)
|
expect(content).toMatch(`const props = __props`)
|
||||||
expect(bindings).toStrictEqual({
|
expect(bindings).toStrictEqual({
|
||||||
foo: BindingTypes.PROPS,
|
foo: BindingTypes.PROPS,
|
||||||
|
@ -424,6 +434,8 @@ const props = defineProps({ foo: String })
|
||||||
quux: BindingTypes.PROPS,
|
quux: BindingTypes.PROPS,
|
||||||
quuxx: BindingTypes.PROPS,
|
quuxx: BindingTypes.PROPS,
|
||||||
fred: BindingTypes.PROPS,
|
fred: BindingTypes.PROPS,
|
||||||
|
toLowerCase: BindingTypes.PROPS,
|
||||||
|
toUpperCase: BindingTypes.PROPS,
|
||||||
props: BindingTypes.SETUP_CONST,
|
props: BindingTypes.SETUP_CONST,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -262,7 +262,7 @@ function genRuntimePropFromType(
|
||||||
} else {
|
} else {
|
||||||
defaultString = `${prop.async ? 'async ' : ''}${
|
defaultString = `${prop.async ? 'async ' : ''}${
|
||||||
prop.kind !== 'method' ? `${prop.kind} ` : ''
|
prop.kind !== 'method' ? `${prop.kind} ` : ''
|
||||||
}default() ${ctx.getString(prop.body)}`
|
}default(${prop.params.map(node => ctx.getString(node)).join(',')}) ${ctx.getString(prop.body)}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue