diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 5ac9f4c700424e71f99f57d1962829f45751e1f3..3dd8183078f03a125f6c91a077a303959e9fd702 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 + } + } } }