@putout/printer 2.62.0 → 2.63.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
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const {parseComments} = require('../../comment/comment');
|
|
4
4
|
|
|
5
|
-
module.exports.printParams = (path, printer, semantics) => {
|
|
5
|
+
module.exports.printParams = (path, printer, semantics, customization = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
params = path.get('params'),
|
|
8
|
+
} = customization;
|
|
9
|
+
|
|
6
10
|
const {print, traverse} = printer;
|
|
7
11
|
|
|
8
12
|
printBraceOpen(path, {
|
|
@@ -11,13 +15,14 @@ module.exports.printParams = (path, printer, semantics) => {
|
|
|
11
15
|
|
|
12
16
|
parseComments(path, printer, semantics);
|
|
13
17
|
|
|
14
|
-
const
|
|
15
|
-
const n = params.length;
|
|
18
|
+
const n = params.length - 1;
|
|
16
19
|
|
|
17
|
-
for (let i = 0; i
|
|
20
|
+
for (let i = 0; i <= n; i++) {
|
|
21
|
+
const isLast = i === n;
|
|
22
|
+
|
|
18
23
|
traverse(params[i]);
|
|
19
24
|
|
|
20
|
-
if (
|
|
25
|
+
if (!isLast) {
|
|
21
26
|
print(',');
|
|
22
27
|
print.space();
|
|
23
28
|
}
|
|
@@ -17,6 +17,8 @@ const {TSInterfaceDeclaration} = require('./interface/ts-interface-declaration')
|
|
|
17
17
|
const {TSAsExpression} = require('./ts-as-expression');
|
|
18
18
|
const {TSInterfaceBody} = require('./interface/ts-interface-body');
|
|
19
19
|
const {TSIntersectionType} = require('./ts-intersection-type');
|
|
20
|
+
const {TSPropertySignature} = require('./ts-property-signature');
|
|
21
|
+
const {TSFunctionType} = require('./ts-function-type');
|
|
20
22
|
|
|
21
23
|
module.exports = {
|
|
22
24
|
TSAsExpression,
|
|
@@ -161,14 +163,6 @@ module.exports = {
|
|
|
161
163
|
TSVoidKeyword(path, {write}) {
|
|
162
164
|
write('void');
|
|
163
165
|
},
|
|
164
|
-
TSFunctionType(path, {print}) {
|
|
165
|
-
print('(');
|
|
166
|
-
print(')');
|
|
167
|
-
print.space();
|
|
168
|
-
print('=>');
|
|
169
|
-
print.space();
|
|
170
|
-
print('__typeAnnotation');
|
|
171
|
-
},
|
|
172
166
|
TSQualifiedName(path, {print}) {
|
|
173
167
|
print('__left');
|
|
174
168
|
print('.');
|
|
@@ -252,17 +246,6 @@ module.exports = {
|
|
|
252
246
|
print('__expression');
|
|
253
247
|
print('__typeParameters');
|
|
254
248
|
},
|
|
255
|
-
TSPropertySignature
|
|
256
|
-
|
|
257
|
-
const typeAnnotation = path.get('typeAnnotation');
|
|
258
|
-
|
|
259
|
-
print('__key');
|
|
260
|
-
maybe.print(optional, '?');
|
|
261
|
-
|
|
262
|
-
if (exists(typeAnnotation)) {
|
|
263
|
-
print(':');
|
|
264
|
-
print.space();
|
|
265
|
-
traverse(typeAnnotation);
|
|
266
|
-
}
|
|
267
|
-
},
|
|
249
|
+
TSPropertySignature,
|
|
250
|
+
TSFunctionType,
|
|
268
251
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {printParams} = require('../expressions/functions/params');
|
|
4
|
+
|
|
5
|
+
module.exports.TSFunctionType = (path, printer, semantics) => {
|
|
6
|
+
const {print} = printer;
|
|
7
|
+
printParams(path, printer, semantics, {
|
|
8
|
+
params: path.get('parameters'),
|
|
9
|
+
});
|
|
10
|
+
print.space();
|
|
11
|
+
print('=>');
|
|
12
|
+
print.space();
|
|
13
|
+
print('__typeAnnotation');
|
|
14
|
+
};
|
|
15
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {exists} = require('../is');
|
|
4
|
+
|
|
5
|
+
module.exports.TSPropertySignature = (path, {print, maybe, traverse}) => {
|
|
6
|
+
const {optional} = path.node;
|
|
7
|
+
const typeAnnotation = path.get('typeAnnotation');
|
|
8
|
+
|
|
9
|
+
print('__key');
|
|
10
|
+
maybe.print(optional, '?');
|
|
11
|
+
|
|
12
|
+
if (exists(typeAnnotation)) {
|
|
13
|
+
print(':');
|
|
14
|
+
print.space();
|
|
15
|
+
traverse(typeAnnotation);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
package/package.json
CHANGED