]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): disallow `expose` property in `defineOptions` (#7967)
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Tue, 28 Mar 2023 09:32:37 +0000 (17:32 +0800)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 09:32:37 +0000 (17:32 +0800)
packages/compiler-sfc/src/compileScript.ts
packages/runtime-core/src/apiSetupHelpers.ts

index 44d998a3c46622f0f431a0808f6d22438dafd029..c253359720cd0b10795e3a41d2ad50a13ef43d5b 100644 (file)
@@ -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 (
@@ -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
         }
       }
     }
@@ -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
   }
index 981e8d60a6a13e7df52ae6cb2ff7304e0bfaca95..bdda22e9398c4a0d5c54955a4dbc44d34a4a63dd 100644 (file)
@@ -169,7 +169,7 @@ export function defineOptions<
     Extends,
     E,
     EE
-  > & { emits?: undefined }
+  > & { emits?: undefined; expose?: undefined }
 ): void {
   if (__DEV__) {
     warnRuntimeUsage(`defineOptions`)