@putout/printer 2.39.0 → 2.41.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/functions/arrow-function-expression.js +1 -0
- package/lib/tokenize/expressions/functions/class-method.js +3 -1
- package/lib/tokenize/expressions/functions/function-declaration.js +3 -1
- package/lib/tokenize/expressions/functions/function-expression.js +1 -0
- package/lib/tokenize/expressions/functions/object-method.js +3 -1
- package/lib/tokenize/expressions/functions/params.js +3 -2
- package/lib/tokenize/literals/index.js +19 -4
- package/lib/tokenize/typescript/index.js +8 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,7 +4,7 @@ const {isNext} = require('../../is');
|
|
|
4
4
|
const {printParams} = require('./params');
|
|
5
5
|
|
|
6
6
|
const ClassMethod = {
|
|
7
|
-
print(path, {print, maybe}) {
|
|
7
|
+
print(path, {print, maybe, traverse}) {
|
|
8
8
|
const {kind, computed} = path.node;
|
|
9
9
|
const isConstructor = kind === 'constructor';
|
|
10
10
|
const isMethod = kind === 'method';
|
|
@@ -26,6 +26,7 @@ const ClassMethod = {
|
|
|
26
26
|
|
|
27
27
|
printParams(path, {
|
|
28
28
|
print,
|
|
29
|
+
traverse,
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
print.space();
|
|
@@ -39,3 +40,4 @@ const ClassMethod = {
|
|
|
39
40
|
|
|
40
41
|
module.exports.ClassPrivateMethod = ClassMethod;
|
|
41
42
|
module.exports.ClassMethod = ClassMethod;
|
|
43
|
+
|
|
@@ -7,7 +7,7 @@ const {isNext, isNextParent} = require('../../is');
|
|
|
7
7
|
const {printParams} = require('./params');
|
|
8
8
|
|
|
9
9
|
module.exports.FunctionDeclaration = {
|
|
10
|
-
print(path, {print, maybe}) {
|
|
10
|
+
print(path, {print, maybe, traverse}) {
|
|
11
11
|
const {async, generator} = path.node;
|
|
12
12
|
|
|
13
13
|
maybe.print(async, 'async ');
|
|
@@ -20,6 +20,7 @@ module.exports.FunctionDeclaration = {
|
|
|
20
20
|
|
|
21
21
|
printParams(path, {
|
|
22
22
|
print,
|
|
23
|
+
traverse,
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
print.space();
|
|
@@ -31,3 +32,4 @@ module.exports.FunctionDeclaration = {
|
|
|
31
32
|
markAfter(path);
|
|
32
33
|
},
|
|
33
34
|
};
|
|
35
|
+
|
|
@@ -10,7 +10,7 @@ module.exports.ObjectMethod = {
|
|
|
10
10
|
before(path, {write}) {
|
|
11
11
|
write('async ');
|
|
12
12
|
},
|
|
13
|
-
print(path, {print, maybe}) {
|
|
13
|
+
print(path, {print, maybe, traverse}) {
|
|
14
14
|
const {
|
|
15
15
|
kind,
|
|
16
16
|
generator,
|
|
@@ -28,6 +28,7 @@ module.exports.ObjectMethod = {
|
|
|
28
28
|
|
|
29
29
|
printParams(path, {
|
|
30
30
|
print,
|
|
31
|
+
traverse,
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
print.space();
|
|
@@ -40,3 +41,4 @@ module.exports.ObjectMethod = {
|
|
|
40
41
|
print.linebreak();
|
|
41
42
|
},
|
|
42
43
|
};
|
|
44
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports.printParams = (path, {print}) => {
|
|
3
|
+
module.exports.printParams = (path, {print, traverse}) => {
|
|
4
4
|
printBraceOpen(path, {
|
|
5
5
|
print,
|
|
6
6
|
});
|
|
@@ -9,7 +9,7 @@ module.exports.printParams = (path, {print}) => {
|
|
|
9
9
|
const n = params.length;
|
|
10
10
|
|
|
11
11
|
for (let i = 0; i < n; i++) {
|
|
12
|
-
|
|
12
|
+
traverse(params[i]);
|
|
13
13
|
|
|
14
14
|
if (i < n - 1) {
|
|
15
15
|
print(',');
|
|
@@ -48,3 +48,4 @@ function isOneArgArrow(path) {
|
|
|
48
48
|
|
|
49
49
|
return param.type === 'Identifier';
|
|
50
50
|
}
|
|
51
|
+
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {TemplateLiteral} = require('./template-literal');
|
|
4
|
+
const maybeDecorators = (path) => {
|
|
5
|
+
if (!path.node.decorators)
|
|
6
|
+
return [];
|
|
7
|
+
|
|
8
|
+
return path.get('decorators');
|
|
9
|
+
};
|
|
4
10
|
|
|
5
11
|
module.exports = {
|
|
6
12
|
TemplateLiteral,
|
|
7
13
|
BigIntLiteral(path, {write}) {
|
|
8
14
|
write(path.node.raw);
|
|
9
15
|
},
|
|
16
|
+
Decorator(path, {print}) {
|
|
17
|
+
print('@');
|
|
18
|
+
print('__expression');
|
|
19
|
+
print(' ');
|
|
20
|
+
},
|
|
10
21
|
NumericLiteral(path, {write}) {
|
|
11
22
|
const {
|
|
12
23
|
raw,
|
|
@@ -24,16 +35,20 @@ module.exports = {
|
|
|
24
35
|
|
|
25
36
|
write(raw || `'${value}'`);
|
|
26
37
|
},
|
|
27
|
-
Identifier(path, {write,
|
|
38
|
+
Identifier(path, {write, maybe, traverse}) {
|
|
28
39
|
const {node} = path;
|
|
29
|
-
const parenthesized = node.extra?.parenthesized;
|
|
30
|
-
|
|
31
40
|
const {name, optional} = node;
|
|
41
|
+
const parenthesized = node.extra?.parenthesized;
|
|
42
|
+
const typeAnnotation = path.get('typeAnnotation');
|
|
32
43
|
|
|
33
44
|
maybe.write(parenthesized, '(');
|
|
45
|
+
for (const decorator of maybeDecorators(path)) {
|
|
46
|
+
traverse(decorator);
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
write(name);
|
|
35
50
|
maybe.write(optional, '?');
|
|
36
|
-
|
|
51
|
+
traverse(typeAnnotation);
|
|
37
52
|
maybe.write(parenthesized, ')');
|
|
38
53
|
},
|
|
39
54
|
RegExpLiteral(path, {print}) {
|
|
@@ -228,6 +228,14 @@ module.exports = {
|
|
|
228
228
|
print.space();
|
|
229
229
|
print('__typeAnnotation');
|
|
230
230
|
},
|
|
231
|
+
TSCallSignatureDeclaration(path, {print}) {
|
|
232
|
+
print('(');
|
|
233
|
+
print('__parameters.0');
|
|
234
|
+
print(')');
|
|
235
|
+
print(':');
|
|
236
|
+
print.space();
|
|
237
|
+
print('__typeAnnotation');
|
|
238
|
+
},
|
|
231
239
|
TSMethodSignature(path, {traverse, write, maybe}) {
|
|
232
240
|
traverse(path.get('key'));
|
|
233
241
|
write('(');
|
package/package.json
CHANGED