Skip to content

Commit

Permalink
fix(compiler-sfc): disallow expose property in defineOptions (#7967)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Mar 28, 2023
1 parent b7bd50f commit 93f7729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ export function compileScript(

let propsOption = undefined
let emitsOption = undefined
let exposeOption = undefined
if (optionsRuntimeDecl.type === 'ObjectExpression') {
for (const prop of optionsRuntimeDecl.properties) {
if (
Expand All @@ -692,6 +693,7 @@ export function compileScript(
) {
if (prop.key.name === 'props') propsOption = prop
if (prop.key.name === 'emits') emitsOption = prop
if (prop.key.name === 'expose') exposeOption = prop
}
}
}
Expand All @@ -708,6 +710,12 @@ export function compileScript(
emitsOption
)
}
if (exposeOption) {
error(
`${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
exposeOption
)
}

return true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function defineOptions<
Extends,
E,
EE
> & { emits?: undefined }
> & { emits?: undefined; expose?: undefined }
): void {
if (__DEV__) {
warnRuntimeUsage(`defineOptions`)
Expand Down

0 comments on commit 93f7729

Please sign in to comment.