fix: 对PropertyAccessExpression做了一定的容错处理

This commit is contained in:
Pan Qiancheng 2025-10-17 14:10:36 +08:00
parent 4f15fe79d0
commit 5c9dae804e
2 changed files with 16 additions and 3 deletions

View File

@ -240,7 +240,7 @@ export const analyzeOakAppDomain = async (
entityDictCache[key] = entityDict[key];
});
console.log('从缓存加载成功');
console.log('从缓存加载成功,文件路径:', cacheFile);
return;
} catch (e) {
console.error('尝试从缓存读取失败', e);

View File

@ -387,9 +387,9 @@ export const getWebComponentPropsData = (
if (!ts.isLiteralTypeNode(args![1])) {
return undefined;
}
const nameRawTextNode = args![1].literal;
const nameRawText = args![1].literal.getText();
entityName = {
value: nameRawText.substring(1, nameRawText.length - 1),
@ -862,7 +862,20 @@ function evaluateExpression(expr: ts.Expression): any {
return null;
} else if (ts.isIdentifier(expr)) {
return expr.text; // 返回标识符名(例如引用类型或枚举名)
} else if (ts.isPropertyAccessExpression(expr)) {
// const left = evaluateExpression(expr.expression);
// const right = expr.name.text;
// if (typeof left === "string") {
// return `${left}.${right}`;
// } else if (left && typeof left === "object" && right in left) {
// return left[right];
// } else {
// return `${left}.${right}`;
// }
return `unresolved`;
} else {
console.log("发现不支持的表达式类型:", ts.SyntaxKind[expr.kind], "在文件", expr.getSourceFile().fileName, "位置", expr.getStart(), "-", expr.getEnd());
throw new Error(`Unsupported expression kind: ${ts.SyntaxKind[expr.kind]}`);
}
}