esrap 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esrap",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Parse in reverse",
5
5
  "repository": {
6
6
  "type": "git",
@@ -501,6 +501,12 @@ export default (options = {}) => {
501
501
  * @param {Context} context
502
502
  */
503
503
  'ClassDeclaration|ClassExpression': (node, context) => {
504
+ if (node.decorators) {
505
+ for (const decorator of node.decorators) {
506
+ context.visit(decorator);
507
+ }
508
+ }
509
+
504
510
  if (node.declare) {
505
511
  context.write('declare ');
506
512
  }
@@ -956,13 +962,28 @@ export default (options = {}) => {
956
962
  },
957
963
 
958
964
  ExportNamedDeclaration(node, context) {
959
- context.write('export ');
960
-
961
965
  if (node.declaration) {
962
- context.visit(node.declaration);
966
+ // Check if declaration has decorators (ClassDeclaration, ClassExpression can have them)
967
+ const decl = /** @type {any} */ (node.declaration);
968
+ if (decl.decorators && decl.decorators.length > 0) {
969
+ for (const decorator of decl.decorators) {
970
+ context.visit(decorator);
971
+ }
972
+ context.write('export ');
973
+ // Temporarily remove decorators so ClassDeclaration doesn't print them again
974
+ const savedDecorators = decl.decorators;
975
+ decl.decorators = [];
976
+ context.visit(node.declaration);
977
+ decl.decorators = savedDecorators;
978
+ } else {
979
+ context.write('export ');
980
+ context.visit(node.declaration);
981
+ }
963
982
  return;
964
983
  }
965
984
 
985
+ context.write('export ');
986
+
966
987
  if (node.exportKind === 'type') {
967
988
  context.write('type ');
968
989
  }