@putout/printer 1.87.0 → 1.89.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 +13 -0
- package/lib/tokenize/expressions/class.js +0 -1
- package/lib/tokenize/statements/block-statement.js +1 -1
- package/lib/tokenize/statements/export-declaration/export-declaration.js +1 -0
- package/lib/tokenize/statements/for-of-statement.js +10 -1
- package/lib/tokenize/statements/variable-declaration.js +2 -1
- package/lib/tokenize/typescript/index.js +11 -0
- package/lib/tokenize/typescript/ts-module-declaration.js +20 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2023.05.09, v1.89.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 17bae21 @putout/printer: rm useless condition
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- bf25bda @putout/printer: ForOfStatement: newline
|
|
8
|
+
|
|
9
|
+
2023.05.09, v1.88.0
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 64aa4a3 @putout/printer: add support of TSModuleDeclaration
|
|
13
|
+
|
|
1
14
|
2023.05.09, v1.87.0
|
|
2
15
|
|
|
3
16
|
feature:
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
const {
|
|
11
11
|
isFirst,
|
|
12
12
|
isNext,
|
|
13
|
+
isLast,
|
|
13
14
|
} = require('../is');
|
|
14
15
|
|
|
15
16
|
module.exports.ForOfStatement = {
|
|
@@ -34,6 +35,9 @@ module.exports.ForOfStatement = {
|
|
|
34
35
|
print(' ');
|
|
35
36
|
print('__body');
|
|
36
37
|
|
|
38
|
+
const {length} = bodyPath.node.body;
|
|
39
|
+
maybe.print.newline(!length && !isLast(path) && !isNext(path));
|
|
40
|
+
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -44,7 +48,12 @@ module.exports.ForOfStatement = {
|
|
|
44
48
|
|
|
45
49
|
maybe.markAfter(isMarkedAfter(bodyPath), path);
|
|
46
50
|
},
|
|
47
|
-
afterIf:
|
|
51
|
+
afterIf: (path) => {
|
|
52
|
+
if (isNext(path))
|
|
53
|
+
return true;
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
},
|
|
48
57
|
after(path, {print}) {
|
|
49
58
|
print.linebreak();
|
|
50
59
|
markAfter(path);
|
|
@@ -13,6 +13,7 @@ const {hasPrevNewline} = require('../mark');
|
|
|
13
13
|
const {isExportDeclaration} = require('@babel/types');
|
|
14
14
|
|
|
15
15
|
const isParentBlock = (path) => /Program|BlockStatement|Export/.test(path.parentPath.type);
|
|
16
|
+
const isInsideBlock = (path) => /^(Program|BlockStatement)$/.test(path.parentPath.type);
|
|
16
17
|
|
|
17
18
|
module.exports.VariableDeclaration = {
|
|
18
19
|
beforeIf: shouldAddNewlineBefore,
|
|
@@ -20,7 +21,7 @@ module.exports.VariableDeclaration = {
|
|
|
20
21
|
print.breakline();
|
|
21
22
|
},
|
|
22
23
|
print(path, {maybe, store, write, traverse}) {
|
|
23
|
-
maybe.indent(
|
|
24
|
+
maybe.indent(isInsideBlock(path));
|
|
24
25
|
write(`${path.node.kind} `);
|
|
25
26
|
|
|
26
27
|
const declarations = path.get('declarations');
|
|
@@ -8,6 +8,11 @@ const {TSConditionalType} = require('./ts-conditional-type');
|
|
|
8
8
|
const {TSTypeParameter} = require('./ts-type-parameter');
|
|
9
9
|
const {TSDeclareFunction} = require('./ts-declare-function');
|
|
10
10
|
|
|
11
|
+
const {
|
|
12
|
+
TSModuleDeclaration,
|
|
13
|
+
TSModuleBlock,
|
|
14
|
+
} = require('./ts-module-declaration');
|
|
15
|
+
|
|
11
16
|
module.exports = {
|
|
12
17
|
TSTypeLiteral,
|
|
13
18
|
TSTypeAliasDeclaration,
|
|
@@ -15,6 +20,12 @@ module.exports = {
|
|
|
15
20
|
TSMappedType,
|
|
16
21
|
TSConditionalType,
|
|
17
22
|
TSDeclareFunction,
|
|
23
|
+
TSModuleDeclaration,
|
|
24
|
+
TSModuleBlock,
|
|
25
|
+
TSTypeQuery(path, {print}) {
|
|
26
|
+
print('typeof ');
|
|
27
|
+
print('__exprName');
|
|
28
|
+
},
|
|
18
29
|
TSNeverKeyword(path, {write}) {
|
|
19
30
|
write('never');
|
|
20
31
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSModuleBlock = (path, {print, traverse, indent}) => {
|
|
4
|
+
print('{');
|
|
5
|
+
print.breakline();
|
|
6
|
+
indent.inc();
|
|
7
|
+
|
|
8
|
+
for (const child of path.get('body'))
|
|
9
|
+
traverse(child);
|
|
10
|
+
|
|
11
|
+
indent.dec();
|
|
12
|
+
print('}');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports.TSModuleDeclaration = (path, {print}) => {
|
|
16
|
+
print('declare namespace ');
|
|
17
|
+
print('__id');
|
|
18
|
+
print.space();
|
|
19
|
+
print('__body');
|
|
20
|
+
};
|
package/package.json
CHANGED