From c33d11ffc3ee8fcc472862abec8c3c7449d7dd98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8A=B1=E6=9E=9C=E5=B1=B1=E5=A4=A7=E5=9C=A3?=
<316783812@qq.com>
Date: Tue, 8 Nov 2022 11:16:21 +0800
Subject: [PATCH] fix(compiler-sfc): fix macro usage in multi-variable
declaration (#6778)
fix #6757
---
.../__snapshots__/compileScript.spec.ts.snap | 17 +++++++++++++++++
.../__tests__/compileScript.spec.ts | 15 +++++++++++++++
packages/compiler-sfc/src/compileScript.ts | 6 +++---
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
index 41c0d472369..9dc932034ba 100644
--- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
+++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
@@ -720,6 +720,23 @@ return { props, a, emit }
}"
`;
+exports[`SFC compile
+ `)
+ assertCode(content)
+ expect(content).toMatch(`const a = 1;`) // test correct removal
+ expect(content).toMatch(`props: ['item'],`)
+ expect(content).toMatch(`emits: ['a'],`)
+ })
+
test('defineProps/defineEmits in multi-variable declaration (full removal)', () => {
const { content } = compile(`