From 07270c60e3d51c63a963f9fb39dbf662ceaed822 Mon Sep 17 00:00:00 2001 From: huiqiangdev Date: Sat, 15 Feb 2025 10:40:11 +0800 Subject: [PATCH] fix @Provide override wrong spelling Signed-off-by: huiqiangdev --- arkoala/ets-plugin/src/utils.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 5ac9f4c70..3dd818307 100644 --- a/arkoala/ets-plugin/src/utils.ts +++ b/arkoala/ets-plugin/src/utils.ts @@ -274,13 +274,18 @@ export function deduceProvideConsumeName(property: ts.PropertyDeclaration, name: } // @Provide({ allowOverride: 'bar'}) bar if (ts.isObjectLiteralExpression(arg)) { - return (arg as ts.ObjectLiteralExpression).properties - .filter( - (property) => - ts.isPropertyAssignment(property) && - property.name.getText() === "allowOveride" - ) - .map((p) => (p as ts.PropertyAssignment).initializer.getText())[0]; + const propertiesName = (arg as ts.ObjectLiteralExpression).properties + .filter( + (property) => + ts.isPropertyAssignment(property) && + property.name.getText() === "allowOverride" + ) + if (propertiesName.length > 0) { + const arg = propertiesName[0] as ts.PropertyAssignment + if (ts.isStringLiteral(arg.initializer)) { + return arg.initializer.text + } + } } } -- Gitee