]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): infer object type for empty type literal
authorEvan You <yyx990803@gmail.com>
Wed, 29 Mar 2023 13:01:52 +0000 (21:01 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 29 Mar 2023 13:01:52 +0000 (21:01 +0800)
packages/compiler-sfc/src/compileScript.ts

index 279a41d081e0a01107e6c744bb7b3763ea1063ce..af54641f4deda6cad4e592dc01a9a166b7fa349c 100644 (file)
@@ -2040,16 +2040,16 @@ function inferRuntimeType(
       // TODO (nice to have) generate runtime property validation
       const types = new Set<string>()
       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']