@putout/printer 2.81.0 → 2.83.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 +3 -0
- package/lib/tokenize/typescript/{ts-declare-function.js → function/ts-declare-function.js} +2 -2
- package/lib/tokenize/typescript/function/ts-declare-method.js +28 -0
- package/lib/tokenize/typescript/index.js +7 -15
- package/lib/tokenize/typescript/tuple/ts-named-tuple-member.js +8 -0
- package/lib/tokenize/typescript/tuple/ts-tuple-type.js +20 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -36,11 +36,14 @@ module.exports.ClassDeclaration = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
39
|
+
const {abstract} = path.node;
|
|
40
|
+
|
|
39
41
|
for (const decorator of maybeDecorators(path)) {
|
|
40
42
|
traverse(decorator);
|
|
41
43
|
print.breakline();
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
maybe.print(abstract, 'abstract ');
|
|
44
47
|
print('class ');
|
|
45
48
|
print('__id');
|
|
46
49
|
print('__typeParameters');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {printParams} = require('
|
|
4
|
-
const {isNext} = require('
|
|
3
|
+
const {printParams} = require('../../expressions/functions/params');
|
|
4
|
+
const {isNext} = require('../../is');
|
|
5
5
|
|
|
6
6
|
const isInsideExport = (path) => {
|
|
7
7
|
return path.parentPath.isExportDefaultDeclaration();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {printParams} = require('../../expressions/functions/params');
|
|
4
|
+
|
|
5
|
+
module.exports.TSDeclareMethod = (path, printer, semantics) => {
|
|
6
|
+
const {print} = printer;
|
|
7
|
+
const {accessibility, abstract} = path.node;
|
|
8
|
+
|
|
9
|
+
if (accessibility) {
|
|
10
|
+
print(accessibility);
|
|
11
|
+
print(' ');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (abstract) {
|
|
15
|
+
print('abstract');
|
|
16
|
+
print(' ');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
print('__key');
|
|
20
|
+
|
|
21
|
+
printParams(path, printer, semantics);
|
|
22
|
+
|
|
23
|
+
print(':');
|
|
24
|
+
print.space();
|
|
25
|
+
print('__returnType');
|
|
26
|
+
print(';');
|
|
27
|
+
print.newline();
|
|
28
|
+
};
|
|
@@ -6,7 +6,8 @@ const {TSTypeAliasDeclaration} = require('./ts-type-alias-declaration');
|
|
|
6
6
|
const {TSMappedType} = require('./ts-mapped-type');
|
|
7
7
|
const {TSConditionalType} = require('./ts-conditional-type');
|
|
8
8
|
const {TSTypeParameter} = require('./ts-type-parameter');
|
|
9
|
-
const {TSDeclareFunction} = require('./ts-declare-function');
|
|
9
|
+
const {TSDeclareFunction} = require('./function/ts-declare-function');
|
|
10
|
+
const {TSDeclareMethod} = require('./function/ts-declare-method');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
TSModuleDeclaration,
|
|
@@ -22,6 +23,8 @@ const {TSFunctionType} = require('./ts-function-type');
|
|
|
22
23
|
const {printParams} = require('../expressions/functions/params');
|
|
23
24
|
const {TSEnumDeclaration} = require('./enum/ts-enum-declaration');
|
|
24
25
|
const {TSEnumMember} = require('./enum/ts-enum-member');
|
|
26
|
+
const {TSTupleType} = require('./tuple/ts-tuple-type');
|
|
27
|
+
const {TSNamedTupleMember} = require('./tuple/ts-named-tuple-member');
|
|
25
28
|
|
|
26
29
|
module.exports = {
|
|
27
30
|
TSAsExpression,
|
|
@@ -59,19 +62,7 @@ module.exports = {
|
|
|
59
62
|
TSLiteralType(path, {print}) {
|
|
60
63
|
print('__literal');
|
|
61
64
|
},
|
|
62
|
-
TSTupleType
|
|
63
|
-
const elementTypes = path.get('elementTypes');
|
|
64
|
-
const n = elementTypes.length - 1;
|
|
65
|
-
|
|
66
|
-
write('[');
|
|
67
|
-
|
|
68
|
-
for (const [i, elementType] of elementTypes.entries()) {
|
|
69
|
-
traverse(elementType);
|
|
70
|
-
maybe.write(i < n, ', ');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
write(']');
|
|
74
|
-
},
|
|
65
|
+
TSTupleType,
|
|
75
66
|
TSInferType(path, {print}) {
|
|
76
67
|
print('infer ');
|
|
77
68
|
print('__typeParameter');
|
|
@@ -258,5 +249,6 @@ module.exports = {
|
|
|
258
249
|
print('__expression');
|
|
259
250
|
print(')');
|
|
260
251
|
},
|
|
252
|
+
TSDeclareMethod,
|
|
253
|
+
TSNamedTupleMember,
|
|
261
254
|
};
|
|
262
|
-
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSTupleType = (path, {write, traverse, indent}) => {
|
|
4
|
+
const elementTypes = path.get('elementTypes');
|
|
5
|
+
|
|
6
|
+
write('[');
|
|
7
|
+
indent.inc();
|
|
8
|
+
write.newline();
|
|
9
|
+
|
|
10
|
+
for (const elementType of elementTypes) {
|
|
11
|
+
indent();
|
|
12
|
+
traverse(elementType);
|
|
13
|
+
write(',');
|
|
14
|
+
write.newline();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
indent.dec();
|
|
18
|
+
indent();
|
|
19
|
+
write(']');
|
|
20
|
+
};
|
package/package.json
CHANGED