From eded94712e37856f258dc8c85f98a26fa41ae05f Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 28 Mar 2023 17:29:31 +0800 Subject: [PATCH] feat(compiler-sfc): improve runtime props inference for enum --- .../__tests__/compileScript.spec.ts | 50 +++++++++++++++++++ packages/compiler-sfc/src/compileScript.ts | 35 ++++++++++--- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/packages/compiler-sfc/__tests__/compileScript.spec.ts b/packages/compiler-sfc/__tests__/compileScript.spec.ts index f375f51ac07..a83029a2525 100644 --- a/packages/compiler-sfc/__tests__/compileScript.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript.spec.ts @@ -1573,6 +1573,56 @@ const emit = defineEmits(['a', 'b']) }) }) + test('runtime inference for Enum in defineProps', () => { + expect( + compile( + ``, + { hoistStatic: true } + ).content + ).toMatch(`foo: { type: Number`) + + expect( + compile( + ``, + { hoistStatic: true } + ).content + ).toMatch(`foo: { type: String`) + + expect( + compile( + ``, + { hoistStatic: true } + ).content + ).toMatch(`foo: { type: [String, Number]`) + + expect( + compile( + ``, + { hoistStatic: true } + ).content + ).toMatch(`foo: { type: Number`) + }) + test('import type', () => { const { content } = compile( `