From: Evan You Date: Wed, 29 Mar 2023 13:01:52 +0000 (+0800) Subject: fix(compiler-sfc): infer object type for empty type literal X-Git-Tag: v3.3.0-alpha.6~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a04fba10b6462303c65f1095da86ce05c14f1f4;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): infer object type for empty type literal --- diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 279a41d081..af54641f4d 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -2040,16 +2040,16 @@ function inferRuntimeType( // TODO (nice to have) generate runtime property validation const types = new Set() for (const m of node.members) { - switch (m.type) { - case 'TSCallSignatureDeclaration': - case 'TSConstructSignatureDeclaration': - types.add('Function') - break - default: - types.add('Object') + if ( + m.type === 'TSCallSignatureDeclaration' || + m.type === 'TSConstructSignatureDeclaration' + ) { + types.add('Function') + } else { + types.add('Object') } } - return Array.from(types) + return types.size ? Array.from(types) : ['Object'] } case 'TSFunctionType': return ['Function']