Skip to content

Commit 5c69895

Browse files
committed
chore: avoid hard error when inferring types
1 parent 4496456 commit 5c69895

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

packages/compiler-sfc/src/script/resolveType.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -1235,26 +1235,25 @@ export function inferRuntimeType(
12351235
try {
12361236
const types = resolveIndexType(ctx, node, scope)
12371237
return flattenTypes(ctx, types, scope)
1238-
} catch (e) {
1239-
// avoid hard error, fallback to unknown
1240-
return [UNKNOWN_TYPE]
1241-
}
1238+
} catch (e) {}
12421239
}
12431240

12441241
case 'ClassDeclaration':
12451242
return ['Object']
12461243

12471244
case 'TSImportType': {
1248-
const sourceScope = importSourceToScope(
1249-
ctx,
1250-
node.argument,
1251-
scope,
1252-
node.argument.value
1253-
)
1254-
const resolved = resolveTypeReference(ctx, node, sourceScope)
1255-
if (resolved) {
1256-
return inferRuntimeType(ctx, resolved, resolved._ownerScope)
1257-
}
1245+
try {
1246+
const sourceScope = importSourceToScope(
1247+
ctx,
1248+
node.argument,
1249+
scope,
1250+
node.argument.value
1251+
)
1252+
const resolved = resolveTypeReference(ctx, node, sourceScope)
1253+
if (resolved) {
1254+
return inferRuntimeType(ctx, resolved, resolved._ownerScope)
1255+
}
1256+
} catch (e) {}
12581257
}
12591258

12601259
default:

0 commit comments

Comments
 (0)