Skip to content

Commit 93f7729

Browse files
authored
fix(compiler-sfc): disallow expose property in defineOptions (#7967)
1 parent b7bd50f commit 93f7729

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
@@ -684,6 +684,7 @@ export function compileScript(
684684

685685
let propsOption = undefined
686686
let emitsOption = undefined
687+
let exposeOption = undefined
687688
if (optionsRuntimeDecl.type === 'ObjectExpression') {
688689
for (const prop of optionsRuntimeDecl.properties) {
689690
if (
@@ -692,6 +693,7 @@ export function compileScript(
692693
) {
693694
if (prop.key.name === 'props') propsOption = prop
694695
if (prop.key.name === 'emits') emitsOption = prop
696+
if (prop.key.name === 'expose') exposeOption = prop
695697
}
696698
}
697699
}
@@ -708,6 +710,12 @@ export function compileScript(
708710
emitsOption
709711
)
710712
}
713+
if (exposeOption) {
714+
error(
715+
`${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
716+
exposeOption
717+
)
718+
}
711719

712720
return true
713721
}

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)