From: 三咲智子 Kevin Deng Date: Tue, 28 Mar 2023 09:34:23 +0000 (+0800) Subject: fix(compiler-sfc): avoid codegen conflict with user variable named `expose` (#7949) X-Git-Tag: v3.3.0-alpha.6~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c839129ab9d46f56a019b0ff234b35f27cac1e35;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): avoid codegen conflict with user variable named `expose` (#7949) rename `expose` to `__expose` to avoid duplicate identifier relate #7890 --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index df4fc952bf..d5714b2234 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -4,8 +4,8 @@ exports[`SFC analyze `) assertCode(content) - expect(content).toMatch(`setup(__props, { expose, emit }) {`) + expect(content).toMatch(`setup(__props, { expose: __expose, emit }) {`) expect(content).toMatch(`emits: ['foo']`) }) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index c253359720..aacc8c6273 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1545,7 +1545,7 @@ export function compileScript( } const destructureElements = - hasDefineExposeCall || !options.inlineTemplate ? [`expose`] : [] + hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [] if (emitIdentifier) { destructureElements.push( emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}` @@ -1723,7 +1723,7 @@ export function compileScript( //