]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: avoid hard error when inferring types
authorEvan You <yyx990803@gmail.com>
Thu, 20 Apr 2023 08:57:36 +0000 (16:57 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 20 Apr 2023 08:57:36 +0000 (16:57 +0800)
packages/compiler-sfc/src/script/resolveType.ts

index f5a52401bbaccbedf2e73e9c1dc42c29cdad4a69..1dc8b16eadf55d28e712cac2d3dad860157ade23 100644 (file)
@@ -1235,26 +1235,25 @@ export function inferRuntimeType(
       try {
         const types = resolveIndexType(ctx, node, scope)
         return flattenTypes(ctx, types, scope)
-      } catch (e) {
-        // avoid hard error, fallback to unknown
-        return [UNKNOWN_TYPE]
-      }
+      } catch (e) {}
     }
 
     case 'ClassDeclaration':
       return ['Object']
 
     case 'TSImportType': {
-      const sourceScope = importSourceToScope(
-        ctx,
-        node.argument,
-        scope,
-        node.argument.value
-      )
-      const resolved = resolveTypeReference(ctx, node, sourceScope)
-      if (resolved) {
-        return inferRuntimeType(ctx, resolved, resolved._ownerScope)
-      }
+      try {
+        const sourceScope = importSourceToScope(
+          ctx,
+          node.argument,
+          scope,
+          node.argument.value
+        )
+        const resolved = resolveTypeReference(ctx, node, sourceScope)
+        if (resolved) {
+          return inferRuntimeType(ctx, resolved, resolved._ownerScope)
+        }
+      } catch (e) {}
     }
 
     default: