From 62c1b2f7dc4d2dd22a1b1ab1897f0ce765008d59 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 28 Jun 2021 16:27:30 -0400 Subject: [PATCH] fix(compiler-sfc): fix defineProps/defineEmits usage in multi-variable declarations fix #3739 --- .../__snapshots__/compileScript.spec.ts.snap | 32 +++++++++++++++++++ .../__tests__/compileScript.spec.ts | 26 +++++++++++++++ packages/compiler-sfc/src/compileScript.ts | 19 +++++++++-- 3 files changed, 74 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 4164124a..36604db2 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -108,6 +108,38 @@ return { props, bar } }" `; +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 decalration (full removal)', () => { + const { content } = compile(` + + `) + assertCode(content) + expect(content).toMatch(`props: ['item'],`) + expect(content).toMatch(`emits: ['a'],`) + }) + test('defineExpose()', () => { const { content } = compile(`