mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): disallow `expose` property in `defineOptions` (#7967)
This commit is contained in:
parent
b7bd50f505
commit
93f77292c9
|
@ -684,6 +684,7 @@ export function compileScript(
|
||||||
|
|
||||||
let propsOption = undefined
|
let propsOption = undefined
|
||||||
let emitsOption = undefined
|
let emitsOption = undefined
|
||||||
|
let exposeOption = undefined
|
||||||
if (optionsRuntimeDecl.type === 'ObjectExpression') {
|
if (optionsRuntimeDecl.type === 'ObjectExpression') {
|
||||||
for (const prop of optionsRuntimeDecl.properties) {
|
for (const prop of optionsRuntimeDecl.properties) {
|
||||||
if (
|
if (
|
||||||
|
@ -692,6 +693,7 @@ export function compileScript(
|
||||||
) {
|
) {
|
||||||
if (prop.key.name === 'props') propsOption = prop
|
if (prop.key.name === 'props') propsOption = prop
|
||||||
if (prop.key.name === 'emits') emitsOption = prop
|
if (prop.key.name === 'emits') emitsOption = prop
|
||||||
|
if (prop.key.name === 'expose') exposeOption = prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,6 +710,12 @@ export function compileScript(
|
||||||
emitsOption
|
emitsOption
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (exposeOption) {
|
||||||
|
error(
|
||||||
|
`${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
|
||||||
|
exposeOption
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ export function defineOptions<
|
||||||
Extends,
|
Extends,
|
||||||
E,
|
E,
|
||||||
EE
|
EE
|
||||||
> & { emits?: undefined }
|
> & { emits?: undefined; expose?: undefined }
|
||||||
): void {
|
): void {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
warnRuntimeUsage(`defineOptions`)
|
warnRuntimeUsage(`defineOptions`)
|
||||||
|
|
Loading…
Reference in New Issue