@putout/printer 2.77.0 → 2.79.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/comment/parse-leading-comments.js +2 -1
- package/lib/tokenize/expressions/{class-property.js → class/class-property.js} +15 -1
- package/lib/tokenize/expressions/index.js +1 -1
- package/lib/tokenize/typescript/enum/ts-enum-declaration.js +21 -0
- package/lib/tokenize/typescript/enum/ts-enum-member.js +10 -0
- package/lib/tokenize/typescript/index.js +14 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {hasTrailingComment} = require('../is');
|
|
4
4
|
const {isVariableDeclarator} = require('@babel/types');
|
|
5
|
+
|
|
5
6
|
const {markBefore} = require('../mark');
|
|
6
7
|
const {maybeInsideFn} = require('./maybe-inside-fn');
|
|
7
8
|
|
|
@@ -50,7 +51,7 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
50
51
|
|
|
51
52
|
print(`/*${value}*/`);
|
|
52
53
|
|
|
53
|
-
if (path.isStatement() || looksLikeDirective || looksLikeMethod || looksLikeProp || looksLikeSwitchCase) {
|
|
54
|
+
if (path.isStatement() || path.isTSEnumMember() || looksLikeDirective || looksLikeMethod || looksLikeProp || looksLikeSwitchCase) {
|
|
54
55
|
print.newline();
|
|
55
56
|
markBefore(path);
|
|
56
57
|
maybe.indent(looksLikeMethod || looksLikeProp || looksLikeSwitchCase);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {exists} = require('
|
|
3
|
+
const {exists} = require('../../is');
|
|
4
4
|
|
|
5
5
|
module.exports.ClassProperty = ClassProperty;
|
|
6
6
|
|
|
@@ -16,9 +16,23 @@ module.exports.PrivateName = (path, {print}) => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
function ClassProperty(path, {print}) {
|
|
19
|
+
const {accessibility} = path.node;
|
|
19
20
|
const value = path.get('value');
|
|
21
|
+
const typeAnnotation = path.get('typeAnnotation');
|
|
22
|
+
|
|
23
|
+
if (accessibility) {
|
|
24
|
+
print(accessibility);
|
|
25
|
+
print(' ');
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
print('__key');
|
|
21
29
|
|
|
30
|
+
if (exists(typeAnnotation)) {
|
|
31
|
+
print(':');
|
|
32
|
+
print.space();
|
|
33
|
+
print(typeAnnotation);
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
if (exists(value)) {
|
|
23
37
|
print.space();
|
|
24
38
|
print('=');
|
|
@@ -24,7 +24,7 @@ const {
|
|
|
24
24
|
ClassProperty,
|
|
25
25
|
ClassPrivateProperty,
|
|
26
26
|
PrivateName,
|
|
27
|
-
} = require('./class-property');
|
|
27
|
+
} = require('./class/class-property');
|
|
28
28
|
|
|
29
29
|
const {AssignmentExpression} = require('./assignment-expression');
|
|
30
30
|
const {ArrayExpression} = require('./array-expression/array-expression');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSEnumDeclaration = (path, {print, traverse, indent}) => {
|
|
4
|
+
print('const ');
|
|
5
|
+
print('enum ');
|
|
6
|
+
print('__id');
|
|
7
|
+
print(' ');
|
|
8
|
+
print('{');
|
|
9
|
+
|
|
10
|
+
indent.inc();
|
|
11
|
+
print.newline();
|
|
12
|
+
|
|
13
|
+
for (const member of path.get('members')) {
|
|
14
|
+
traverse(member);
|
|
15
|
+
print(',');
|
|
16
|
+
print.newline();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
indent.dec();
|
|
20
|
+
print('}');
|
|
21
|
+
};
|
|
@@ -20,6 +20,8 @@ const {TSIntersectionType} = require('./ts-intersection-type');
|
|
|
20
20
|
const {TSPropertySignature} = require('./ts-property-signature');
|
|
21
21
|
const {TSFunctionType} = require('./ts-function-type');
|
|
22
22
|
const {printParams} = require('../expressions/functions/params');
|
|
23
|
+
const {TSEnumDeclaration} = require('./enum/ts-enum-declaration');
|
|
24
|
+
const {TSEnumMember} = require('./enum/ts-enum-member');
|
|
23
25
|
|
|
24
26
|
module.exports = {
|
|
25
27
|
TSAsExpression,
|
|
@@ -239,5 +241,16 @@ module.exports = {
|
|
|
239
241
|
print('__expression');
|
|
240
242
|
print('!');
|
|
241
243
|
},
|
|
244
|
+
TSEnumDeclaration,
|
|
245
|
+
TSEnumMember,
|
|
246
|
+
TSImportEqualsDeclaration(path, {print}) {
|
|
247
|
+
print('import ');
|
|
248
|
+
print('__id');
|
|
249
|
+
print.space();
|
|
250
|
+
print('=');
|
|
251
|
+
print.space();
|
|
252
|
+
print('__moduleReference');
|
|
253
|
+
print(';');
|
|
254
|
+
print.newline();
|
|
255
|
+
},
|
|
242
256
|
};
|
|
243
|
-
|
package/package.json
CHANGED