diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 8204aab492eac2914ddba76d80ca5b762d6f0b82..b1ff71a9d6f93abf48c9afefe7ec06d9cbbca4d0 100644 --- a/arkoala/ets-plugin/src/utils.ts +++ b/arkoala/ets-plugin/src/utils.ts @@ -263,7 +263,7 @@ export function deduceProvideConsumeName(property: ts.PropertyDeclaration, name: if (ts.isIdentifier(decorator.expression)) { return idTextOrError(property.name) } - // @Provide("bar") foo + // @Provide("bar") foo && @Provide({ allowOverride: 'bar'}) bar if (ts.isCallExpression(decorator.expression)) { const arg = decorator.expression.arguments[0]! if (ts.isIdentifier(arg)) { @@ -272,6 +272,16 @@ export function deduceProvideConsumeName(property: ts.PropertyDeclaration, name: if (ts.isStringLiteral(arg)) { return arg.text } + // @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]; + } } throw new Error("Unexpected decorator kind: " + asString(decorator.expression))