@putout/printer 2.46.0 → 2.48.0

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/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ 2023.07.05, v2.48.0
2
+
3
+ feature:
4
+ - 580a8ff @putout/printer: typescript: TSInterfaceDeclaration: empty body
5
+
6
+ 2023.07.05, v2.47.0
7
+
8
+ feature:
9
+ - dc0ba73 @putout/printer: Program: improve support of inner comments
10
+
1
11
  2023.07.04, v2.46.0
2
12
 
3
13
  feature:
@@ -3,9 +3,9 @@
3
3
  const {
4
4
  hasTrailingComment,
5
5
  isLast,
6
- } = require('./is');
6
+ } = require('../is');
7
7
 
8
- const {markBefore} = require('./mark');
8
+ const {markBefore} = require('../mark');
9
9
  const {isVariableDeclarator} = require('@babel/types');
10
10
 
11
11
  module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics) => {
@@ -99,6 +99,13 @@ module.exports.parseComments = (path, {write}, semantics) => {
99
99
  write('//');
100
100
  write(value);
101
101
  write.newline();
102
+ continue;
103
+ }
104
+
105
+ if (type === 'CommentBlock') {
106
+ write('/*');
107
+ write(value);
108
+ write('*/');
102
109
  }
103
110
  }
104
111
  };
@@ -11,7 +11,7 @@ const {
11
11
  exists,
12
12
  } = require('../../is');
13
13
 
14
- const {parseComments} = require('../../comments');
14
+ const {parseComments} = require('../../comments/comments');
15
15
  const {isSpreadElement} = require('@babel/types');
16
16
 
17
17
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
@@ -71,4 +71,3 @@ module.exports = {
71
71
  write('super');
72
72
  },
73
73
  };
74
-
@@ -13,7 +13,7 @@ const {
13
13
  } = require('@babel/types');
14
14
 
15
15
  const {markAfter} = require('../../mark');
16
- const {parseComments} = require('../../comments');
16
+ const {parseComments} = require('../../comments/comments');
17
17
  const {insideIfWithNoBody} = require('./inside-if-with-no-body');
18
18
 
19
19
  const isFirstStatement = (path) => path.node.body[0];
@@ -19,6 +19,7 @@ const {ForInStatement} = require('./for-in-statement');
19
19
  const {ExportDefaultDeclaration} = require('./export-declaration/export-default-declaration');
20
20
  const {BreakStatement} = require('./break-statement');
21
21
  const {DoWhileStatement} = require('./do-while-statement');
22
+ const {Program} = require('./program');
22
23
 
23
24
  const {
24
25
  ExportNamespaceSpecifier,
@@ -48,15 +49,7 @@ module.exports = {
48
49
  print.space();
49
50
  print('__body');
50
51
  },
51
- Program(path, {print}) {
52
- print('__interpreter');
53
-
54
- path
55
- .get('body')
56
- .forEach(print);
57
-
58
- print.newline();
59
- },
52
+ Program,
60
53
  EmptyStatement(path, {write}) {
61
54
  write(';');
62
55
  },
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const {parseComments} = require('../comments/comments');
4
+
5
+ module.exports.Program = (path, {print, write}, semantics) => {
6
+ print('__interpreter');
7
+ parseComments(path, {write}, semantics);
8
+
9
+ path
10
+ .get('body')
11
+ .forEach(print);
12
+
13
+ print.newline();
14
+ };
@@ -13,7 +13,7 @@ const {isExportDeclaration} = require('@babel/types');
13
13
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
14
14
 
15
15
  const {isConcatenation} = require('../../expressions/binary-expression/concatanate');
16
- const {parseLeadingComments} = require('../../comments');
16
+ const {parseLeadingComments} = require('../../comments/comments');
17
17
 
18
18
  const isParentBlock = (path) => /Program|BlockStatement|Export/.test(path.parentPath.type);
19
19
  const isInsideBlock = (path) => /^(Program|BlockStatement)$/.test(path.parentPath.type);
@@ -27,7 +27,7 @@ const {
27
27
  const {
28
28
  parseLeadingComments,
29
29
  parseTrailingComments,
30
- } = require('./comments');
30
+ } = require('./comments/comments');
31
31
 
32
32
  const {parseOverrides} = require('./overrides');
33
33
 
@@ -13,8 +13,9 @@ const {
13
13
  TSModuleBlock,
14
14
  } = require('./ts-module-declaration');
15
15
 
16
- const {TSInterfaceDeclaration} = require('./ts-interface-declaration');
16
+ const {TSInterfaceDeclaration} = require('./interface/ts-interface-declaration');
17
17
  const {TSAsExpression} = require('./ts-as-expression');
18
+ const {TSInterfaceBody} = require('./interface/ts-interface-body');
18
19
 
19
20
  module.exports = {
20
21
  TSAsExpression,
@@ -104,21 +105,7 @@ module.exports = {
104
105
  print('__typeAnnotation');
105
106
  },
106
107
  TSInterfaceDeclaration,
107
- TSInterfaceBody(path, {traverse, write, indent}) {
108
- write(' {');
109
- write.newline();
110
- indent.inc();
111
-
112
- for (const item of path.get('body')) {
113
- indent();
114
- traverse(item);
115
- write(';');
116
- write.newline();
117
- }
118
-
119
- indent.dec();
120
- write('}');
121
- },
108
+ TSInterfaceBody,
122
109
  TSTypeAssertion(path, {print}) {
123
110
  print('<');
124
111
  print('__typeAnnotation');
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ module.exports.TSInterfaceBody = (path, {traverse, write, indent, maybe}) => {
4
+ const body = path.get('body');
5
+ write.space();
6
+ write('{');
7
+ maybe.write.newline(body.length);
8
+ indent.inc();
9
+
10
+ for (const item of body) {
11
+ indent();
12
+ traverse(item);
13
+ write(';');
14
+ write.newline();
15
+ }
16
+
17
+ indent.dec();
18
+ write('}');
19
+ };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isNext} = require('../is');
3
+ const {isNext} = require('../../is');
4
4
 
5
5
  module.exports.TSInterfaceDeclaration = {
6
6
  print(path, {print}) {
@@ -14,3 +14,4 @@ module.exports.TSInterfaceDeclaration = {
14
14
  print.breakline();
15
15
  },
16
16
  };
17
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.46.0",
3
+ "version": "2.48.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",