diff --git a/static_core/plugins/ets/tools/declgen_ts2sts/src/ASTAutofixer.ts b/static_core/plugins/ets/tools/declgen_ts2sts/src/ASTAutofixer.ts index 7874d3d7b1a4505a4cc0ad1bf45863b03c4b3ff4..509c656485657b240f2a4ba142a4221481569d87 100644 --- a/static_core/plugins/ets/tools/declgen_ts2sts/src/ASTAutofixer.ts +++ b/static_core/plugins/ets/tools/declgen_ts2sts/src/ASTAutofixer.ts @@ -923,10 +923,16 @@ export class Autofixer { return modifier.kind === ts.SyntaxKind.PrivateKeyword; })); }); - const nodeCanHaveModifiers = ts.canHaveModifiers(node); - const validModifiers = nodeCanHaveModifiers ? ts.getModifiers(node) : undefined; - return ts.factory.createClassDeclaration( - validModifiers, + + const decorators = ts.getAllDecorators(node) ?? []; + const modifiers = ts.canHaveModifiers(node) ? (ts.getModifiers(node) ?? []) : []; + + const modifierLike: ts.NodeArray | undefined = (decorators.length || modifiers.length) ? + ts.factory.createNodeArray([...decorators, ...modifiers]) : undefined; + + return this.context.factory.updateClassDeclaration( + node, + modifierLike, node.name, node.typeParameters, node.heritageClauses, @@ -988,7 +994,6 @@ export class Autofixer { if (!isExported) { return node; } - const hasDeclare = modifiers.some(m => m.kind === ts.SyntaxKind.DeclareKeyword); if (hasDeclare) { return node; @@ -1276,7 +1281,7 @@ export class Autofixer { } let decorators: ts.Decorator[] = []; - + const illegalDecorators = ts.getAllDecorators(node) decorators = illegalDecorators?.filter(ts.isDecorator) as ts.Decorator[]; // Filter out restricted decorators