From bad0942a9c2c3878827cef13209eba0a44569f88 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: Wed, 29 Mar 2023 00:58:05 +0800 Subject: [PATCH] fix(compiler-sfc): infer runtime type in defineProps --- packages/compiler-sfc/src/compileScript.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 3ec54e8010a..a71f9c777d3 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -2068,7 +2068,7 @@ function inferRuntimeType( case 'BigIntLiteral': return ['Number'] default: - return [`UNKNOWN`] + return [UNKNOWN_TYPE] } case 'TSTypeReference': @@ -2116,6 +2116,7 @@ function inferRuntimeType( declaredTypes ).filter(t => t !== 'null') } + break case 'Extract': if (node.typeParameters && node.typeParameters.params[1]) { return inferRuntimeType( @@ -2123,6 +2124,7 @@ function inferRuntimeType( declaredTypes ) } + break case 'Exclude': case 'OmitThisParameter': if (node.typeParameters && node.typeParameters.params[0]) { @@ -2131,9 +2133,10 @@ function inferRuntimeType( declaredTypes ) } - // cannot infer, fallback to UNKNOWN: ThisParameterType + break } } + // cannot infer, fallback to UNKNOWN: ThisParameterType return [UNKNOWN_TYPE] case 'TSParenthesizedType':