@putout/printer 1.38.0 → 1.39.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
|
@@ -106,13 +106,13 @@ module.exports.FunctionDeclaration = (path, {print, maybe}) => {
|
|
|
106
106
|
print('__body');
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
module.exports.ClassMethod = (path, {print}) => {
|
|
109
|
+
module.exports.ClassMethod = (path, {print, maybe}) => {
|
|
110
110
|
const {kind} = path.node;
|
|
111
|
+
const notMethod = kind !== 'method';
|
|
112
|
+
const notConstructor = kind !== 'constructor';
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
print('__key');
|
|
114
|
+
maybe.print(notMethod, `${kind} `);
|
|
115
|
+
maybe.print(notConstructor, '__key');
|
|
116
116
|
print('(');
|
|
117
117
|
|
|
118
118
|
const params = path.get('params');
|
|
@@ -128,3 +128,4 @@ module.exports.ClassMethod = (path, {print}) => {
|
|
|
128
128
|
print(') ');
|
|
129
129
|
print('__body');
|
|
130
130
|
};
|
|
131
|
+
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports.ExportDefaultDeclaration =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
module.exports.ExportDefaultDeclaration = {
|
|
4
|
+
beforeIf(path) {
|
|
5
|
+
return path.getPrevSibling().isTSTypeAliasDeclaration();
|
|
6
|
+
},
|
|
7
|
+
before(path, {print}) {
|
|
8
|
+
print.breakline();
|
|
9
|
+
},
|
|
10
|
+
print(path, {print, traverse, maybe}) {
|
|
11
|
+
const declaration = path.get('declaration');
|
|
12
|
+
print('export default ');
|
|
13
|
+
traverse(declaration);
|
|
14
|
+
maybe.print(!declaration.isClassDeclaration(), ';');
|
|
15
|
+
},
|
|
7
16
|
};
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const {exists} = require('../is');
|
|
4
4
|
const {TSTypeLiteral} = require('./ts-type-literal');
|
|
5
|
+
const {TSTypeAliasDeclaration} = require('./ts-type-alias-declaration');
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
7
8
|
TSTypeLiteral,
|
|
9
|
+
TSTypeAliasDeclaration,
|
|
8
10
|
TSTypeParameterDeclaration(path, {print}) {
|
|
9
11
|
print('<');
|
|
10
12
|
|
|
@@ -50,6 +52,16 @@ module.exports = {
|
|
|
50
52
|
print.space();
|
|
51
53
|
print('__typeAnnotation');
|
|
52
54
|
},
|
|
55
|
+
TSQualifiedName(path, {print}) {
|
|
56
|
+
print('__left');
|
|
57
|
+
print('.');
|
|
58
|
+
print('__right');
|
|
59
|
+
},
|
|
60
|
+
TSParameterProperty(path, {write, print}) {
|
|
61
|
+
write(path.node.accessibility);
|
|
62
|
+
write.space();
|
|
63
|
+
print('__parameter');
|
|
64
|
+
},
|
|
53
65
|
TSTypeAnnotation(path, {print}) {
|
|
54
66
|
if (path.parentPath.isIdentifier()) {
|
|
55
67
|
print(':');
|
|
@@ -62,15 +74,6 @@ module.exports = {
|
|
|
62
74
|
print('__expression');
|
|
63
75
|
print('__typeParameters');
|
|
64
76
|
},
|
|
65
|
-
TSTypeAliasDeclaration(path, {print}) {
|
|
66
|
-
print('type ');
|
|
67
|
-
print('__id');
|
|
68
|
-
print.space();
|
|
69
|
-
print('=');
|
|
70
|
-
print.space();
|
|
71
|
-
print('__typeAnnotation');
|
|
72
|
-
print(';');
|
|
73
|
-
},
|
|
74
77
|
TSPropertySignature(path, {print, maybe, traverse}) {
|
|
75
78
|
const {optional} = path.node;
|
|
76
79
|
const typeAnnotation = path.get('typeAnnotation');
|
|
@@ -85,3 +88,4 @@ module.exports = {
|
|
|
85
88
|
}
|
|
86
89
|
},
|
|
87
90
|
};
|
|
91
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {isLast} = require('../is');
|
|
4
|
+
module.exports.TSTypeAliasDeclaration = {
|
|
5
|
+
print(path, {print}) {
|
|
6
|
+
print('type ');
|
|
7
|
+
print('__id');
|
|
8
|
+
print.space();
|
|
9
|
+
print('=');
|
|
10
|
+
print.space();
|
|
11
|
+
print('__typeAnnotation');
|
|
12
|
+
print(';');
|
|
13
|
+
},
|
|
14
|
+
afterIf(path) {
|
|
15
|
+
return !isLast(path);
|
|
16
|
+
},
|
|
17
|
+
after(path, {print}) {
|
|
18
|
+
print.newline();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|