@putout/printer 5.14.0 → 5.16.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 +11 -0
- package/lib/tokenize/typescript/enum/ts-enum-declaration.js +30 -17
- package/lib/tokenize/typescript/function/ts-declare-function.js +1 -1
- package/lib/tokenize/typescript/function/ts-declare-method.js +0 -1
- package/lib/tokenize/typescript/function/ts-method-signature.js +2 -0
- package/lib/tokenize/typescript/interface/ts-interface-body.js +2 -0
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +4 -1
- package/lib/tokenize/typescript/namespace/ts-module-declaration.js +9 -2
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2023.10.02, v5.16.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ac06127 @putout/printer: TSModuleDeclaration: module
|
|
5
|
+
|
|
6
|
+
2023.10.02, v5.15.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 209cdd5 @putout/printer: TSEnumDeclaration: not const
|
|
10
|
+
- 49837dc package: @putout/plugin-printer v3.0.0
|
|
11
|
+
|
|
1
12
|
2023.10.02, v5.14.0
|
|
2
13
|
|
|
3
14
|
feature:
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
print('
|
|
3
|
+
const {isNext, isNextParent} = require('../../is');
|
|
4
|
+
|
|
5
|
+
module.exports.TSEnumDeclaration = {
|
|
6
|
+
beforeIf(path) {
|
|
7
|
+
return path.node.const;
|
|
8
|
+
},
|
|
9
|
+
before(path, {print}) {
|
|
10
|
+
print('const ');
|
|
11
|
+
},
|
|
12
|
+
print(path, {print, traverse, indent}) {
|
|
13
|
+
print('enum ');
|
|
14
|
+
print('__id');
|
|
15
|
+
print(' ');
|
|
16
|
+
print('{');
|
|
17
|
+
|
|
18
|
+
indent.inc();
|
|
16
19
|
print.newline();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
for (const member of path.get('members')) {
|
|
22
|
+
traverse(member);
|
|
23
|
+
print(',');
|
|
24
|
+
print.newline();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
indent.dec();
|
|
28
|
+
print('}');
|
|
29
|
+
},
|
|
30
|
+
afterSatisfy: () => [isNext, isNextParent],
|
|
31
|
+
after(path, {print}) {
|
|
32
|
+
print.breakline();
|
|
33
|
+
},
|
|
21
34
|
};
|
|
@@ -13,6 +13,7 @@ module.exports.TSDeclareFunction = (path, printer, semantics) => {
|
|
|
13
13
|
maybe,
|
|
14
14
|
indent,
|
|
15
15
|
} = printer;
|
|
16
|
+
|
|
16
17
|
const {declare} = path.node;
|
|
17
18
|
|
|
18
19
|
indent();
|
|
@@ -31,4 +32,3 @@ module.exports.TSDeclareFunction = (path, printer, semantics) => {
|
|
|
31
32
|
maybe.print.newline(isNext(path) || isNext(path.parentPath));
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
|
|
@@ -11,6 +11,7 @@ module.exports.TSMethodSignature = (path, printer, semantics) => {
|
|
|
11
11
|
const {traverse, write} = printer;
|
|
12
12
|
|
|
13
13
|
traverse(path.get('key'));
|
|
14
|
+
traverse(path.get('typeParameters'));
|
|
14
15
|
printParams(path, printer, semantics);
|
|
15
16
|
|
|
16
17
|
if (hasReturnType(path)) {
|
|
@@ -19,3 +20,4 @@ module.exports.TSMethodSignature = (path, printer, semantics) => {
|
|
|
19
20
|
printReturnType(path, printer);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
23
|
+
|
|
@@ -9,9 +9,11 @@ const {isNext, isNextParent} = require('../../is');
|
|
|
9
9
|
const {maybeDeclare} = require('../namespace/maybeDeclare');
|
|
10
10
|
|
|
11
11
|
module.exports.TSInterfaceDeclaration = {
|
|
12
|
-
print: maybeDeclare((path, {print}) => {
|
|
12
|
+
print: maybeDeclare((path, {print, indent}) => {
|
|
13
|
+
indent();
|
|
13
14
|
print('interface ');
|
|
14
15
|
print('__id');
|
|
16
|
+
print('__typeParameters');
|
|
15
17
|
print('__body');
|
|
16
18
|
}),
|
|
17
19
|
afterSatisfy: () => [isNext, isNextParent],
|
|
@@ -24,3 +26,4 @@ module.exports.TSInterfaceDeclaration = {
|
|
|
24
26
|
print.breakline();
|
|
25
27
|
},
|
|
26
28
|
};
|
|
29
|
+
|
|
@@ -5,7 +5,13 @@ const {maybeDeclare} = require('./maybeDeclare');
|
|
|
5
5
|
|
|
6
6
|
module.exports.TSModuleDeclaration = {
|
|
7
7
|
print: maybeDeclare((path, {print}) => {
|
|
8
|
-
|
|
8
|
+
const id = path.get('id');
|
|
9
|
+
|
|
10
|
+
if (id.isStringLiteral())
|
|
11
|
+
print('module ');
|
|
12
|
+
else
|
|
13
|
+
print('namespace ');
|
|
14
|
+
|
|
9
15
|
print('__id');
|
|
10
16
|
print.space();
|
|
11
17
|
print('__body');
|
|
@@ -22,8 +28,9 @@ module.exports.TSModuleBlock = (path, {print, traverse, indent}) => {
|
|
|
22
28
|
print.breakline();
|
|
23
29
|
indent.inc();
|
|
24
30
|
|
|
25
|
-
for (const child of path.get('body'))
|
|
31
|
+
for (const child of path.get('body')) {
|
|
26
32
|
traverse(child);
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
indent.dec();
|
|
29
36
|
print('}');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
|
|
49
49
|
"@putout/plugin-minify": "^4.0.0",
|
|
50
|
-
"@putout/plugin-printer": "^
|
|
50
|
+
"@putout/plugin-printer": "^3.0.0",
|
|
51
51
|
"@putout/plugin-promises": "^13.0.0",
|
|
52
52
|
"@putout/plugin-react-hook-form": "^4.0.0",
|
|
53
53
|
"@putout/plugin-react-hooks": "^5.0.0",
|