Skip to content

Commit

Permalink
chore: avoid hard error when inferring types
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 20, 2023
1 parent 4496456 commit 5c69895
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions packages/compiler-sfc/src/script/resolveType.ts
Expand Up @@ -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:
Expand Down

0 comments on commit 5c69895

Please sign in to comment.