@putout/printer 5.15.0 → 5.17.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 +10 -0
- package/lib/tokenize/expressions/class/class.js +18 -10
- package/lib/tokenize/typescript/function/ts-method-signature.js +1 -0
- package/lib/tokenize/typescript/interface/ts-interface-body.js +2 -0
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +3 -1
- package/lib/tokenize/typescript/namespace/ts-module-declaration.js +9 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,21 +4,17 @@ const {isNext} = require('../../is');
|
|
|
4
4
|
const {markAfter} = require('../../mark');
|
|
5
5
|
const {maybeDecorators} = require('../../maybe-get');
|
|
6
6
|
const {maybeDeclare} = require('../../typescript/namespace/maybeDeclare');
|
|
7
|
+
const {parseComments} = require('../../comment/comment');
|
|
7
8
|
|
|
8
9
|
const isInsideExport = ({parentPath}) => parentPath.isExportDeclaration();
|
|
9
10
|
|
|
10
11
|
module.exports.ClassExpression = classVisitor;
|
|
11
12
|
|
|
12
13
|
module.exports.ClassDeclaration = {
|
|
13
|
-
print: maybeDeclare((path,
|
|
14
|
+
print: maybeDeclare((path, printer, semantics) => {
|
|
15
|
+
const {indent} = printer;
|
|
14
16
|
indent();
|
|
15
|
-
|
|
16
|
-
classVisitor(path, {
|
|
17
|
-
print,
|
|
18
|
-
indent,
|
|
19
|
-
maybe,
|
|
20
|
-
traverse,
|
|
21
|
-
});
|
|
17
|
+
classVisitor(path, printer, semantics);
|
|
22
18
|
}),
|
|
23
19
|
afterIf(path) {
|
|
24
20
|
if (!isNext(path))
|
|
@@ -36,8 +32,14 @@ module.exports.ClassDeclaration = {
|
|
|
36
32
|
},
|
|
37
33
|
};
|
|
38
34
|
|
|
39
|
-
function classVisitor(path,
|
|
35
|
+
function classVisitor(path, printer, semantics) {
|
|
40
36
|
const {id, abstract} = path.node;
|
|
37
|
+
const {
|
|
38
|
+
print,
|
|
39
|
+
indent,
|
|
40
|
+
maybe,
|
|
41
|
+
traverse,
|
|
42
|
+
} = printer;
|
|
41
43
|
|
|
42
44
|
for (const decorator of maybeDecorators(path)) {
|
|
43
45
|
traverse(decorator);
|
|
@@ -69,14 +71,20 @@ function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
|
69
71
|
maybe.print.newline(path.node.body.body.length);
|
|
70
72
|
indent.inc();
|
|
71
73
|
|
|
72
|
-
const
|
|
74
|
+
const classBody = path.get('body');
|
|
75
|
+
const body = classBody.get('body');
|
|
73
76
|
|
|
74
77
|
for (const item of body) {
|
|
75
78
|
indent();
|
|
76
79
|
traverse(item);
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
if (!body.length) {
|
|
83
|
+
parseComments(classBody, printer, semantics);
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
indent.dec();
|
|
80
87
|
maybe.indent(body.length);
|
|
81
88
|
print('}');
|
|
82
89
|
}
|
|
90
|
+
|
|
@@ -9,9 +9,11 @@ const {isNext, isNextParent} = require('../../is');
|
|
|
9
9
|
const {maybeDeclare} = require('../namespace/maybeDeclare');
|
|
10
10
|
|
|
11
11
|
module.exports.TSInterfaceDeclaration = {
|
|
12
|
-
print: maybeDeclare((path, {print}) => {
|
|
12
|
+
print: maybeDeclare((path, {print, indent}) => {
|
|
13
|
+
indent();
|
|
13
14
|
print('interface ');
|
|
14
15
|
print('__id');
|
|
16
|
+
print('__typeParameters');
|
|
15
17
|
print('__body');
|
|
16
18
|
}),
|
|
17
19
|
afterSatisfy: () => [isNext, isNextParent],
|
|
@@ -5,7 +5,13 @@ const {maybeDeclare} = require('./maybeDeclare');
|
|
|
5
5
|
|
|
6
6
|
module.exports.TSModuleDeclaration = {
|
|
7
7
|
print: maybeDeclare((path, {print}) => {
|
|
8
|
-
|
|
8
|
+
const id = path.get('id');
|
|
9
|
+
|
|
10
|
+
if (id.isStringLiteral())
|
|
11
|
+
print('module ');
|
|
12
|
+
else
|
|
13
|
+
print('namespace ');
|
|
14
|
+
|
|
9
15
|
print('__id');
|
|
10
16
|
print.space();
|
|
11
17
|
print('__body');
|
|
@@ -22,8 +28,9 @@ module.exports.TSModuleBlock = (path, {print, traverse, indent}) => {
|
|
|
22
28
|
print.breakline();
|
|
23
29
|
indent.inc();
|
|
24
30
|
|
|
25
|
-
for (const child of path.get('body'))
|
|
31
|
+
for (const child of path.get('body')) {
|
|
26
32
|
traverse(child);
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
indent.dec();
|
|
29
36
|
print('}');
|
package/package.json
CHANGED