From 0afb7b44372d0c2fde148c3f30ec3bd95e5c38a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 12 May 2023 20:25:06 +0800 Subject: [PATCH] test: add --- .../__snapshots__/defineEmits.spec.ts.snap | 18 ++++++++++++++++++ .../compileScript/defineEmits.spec.ts | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineEmits.spec.ts.snap b/packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineEmits.spec.ts.snap index 729c019a555..a8bd930fbbc 100644 --- a/packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineEmits.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineEmits.spec.ts.snap @@ -191,6 +191,24 @@ export default /*#__PURE__*/_defineComponent({ +return { emit } +} + +})" +`; + +exports[`defineEmits > w/ type (type references in union) 1`] = ` +"import { defineComponent as _defineComponent } from 'vue' +type BaseEmit = \\"change\\" + type Emit = \\"some\\" | \\"emit\\" | BaseEmit + +export default /*#__PURE__*/_defineComponent({ + emits: [\\"some\\", \\"emit\\", \\"change\\", \\"another\\"], + setup(__props, { expose: __expose, emit }) { + __expose(); + + + return { emit } } diff --git a/packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts b/packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts index 67d9674b54c..c5d2900a4e7 100644 --- a/packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts @@ -179,6 +179,23 @@ const emit = defineEmits(['a', 'b']) assertCode(content) }) + // #7943 + test('w/ type (type references in union)', () => { + const { content } = compile(` + + `) + + expect(content).toMatch(`emits: ["some", "emit", "change", "another"]`) + assertCode(content) + }) + describe('errors', () => { test('w/ both type and non-type args', () => { expect(() => {