Skip to content

Commit b9e9c75

Browse files
committed
fix(compiler-sfc): disallow expose property in defineOptions
1 parent 3a7572c commit b9e9c75

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/compiler-sfc/src/compileScript.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ export function compileScript(
676676

677677
let propsOption = undefined
678678
let emitsOption = undefined
679+
let exposeOption = undefined
679680
if (optionsRuntimeDecl.type === 'ObjectExpression') {
680681
for (const prop of optionsRuntimeDecl.properties) {
681682
if (
@@ -684,6 +685,7 @@ export function compileScript(
684685
) {
685686
if (prop.key.name === 'props') propsOption = prop
686687
if (prop.key.name === 'emits') emitsOption = prop
688+
if (prop.key.name === 'expose') exposeOption = prop
687689
}
688690
}
689691
}
@@ -700,6 +702,12 @@ export function compileScript(
700702
emitsOption
701703
)
702704
}
705+
if (exposeOption) {
706+
error(
707+
`${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
708+
exposeOption
709+
)
710+
}
703711

704712
return true
705713
}

packages/runtime-core/src/apiSetupHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function defineOptions<
169169
Extends,
170170
E,
171171
EE
172-
> & { emits?: undefined }
172+
> & { emits?: undefined; expose?: undefined }
173173
): void {
174174
if (__DEV__) {
175175
warnRuntimeUsage(`defineOptions`)

0 commit comments

Comments
 (0)