From: Evan You Date: Thu, 20 Apr 2023 08:57:36 +0000 (+0800) Subject: chore: avoid hard error when inferring types X-Git-Tag: v3.3.0-alpha.13~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c6989557dafb7f7b3d2bb225618c83c70a4e12e;p=thirdparty%2Fvuejs%2Fcore.git chore: avoid hard error when inferring types --- diff --git a/packages/compiler-sfc/src/script/resolveType.ts b/packages/compiler-sfc/src/script/resolveType.ts index f5a52401bb..1dc8b16ead 100644 --- a/packages/compiler-sfc/src/script/resolveType.ts +++ b/packages/compiler-sfc/src/script/resolveType.ts @@ -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: