@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 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
- 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(',');
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
- indent.dec();
20
- print('}');
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
-
@@ -33,4 +33,3 @@ module.exports.TSDeclareMethod = (path, printer, semantics) => {
33
33
  print(';');
34
34
  print.newline();
35
35
  };
36
-
@@ -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
+
@@ -15,5 +15,7 @@ module.exports.TSInterfaceBody = (path, {traverse, write, indent, maybe}) => {
15
15
  }
16
16
 
17
17
  indent.dec();
18
+ indent();
18
19
  write('}');
20
+ maybe.write.newline(path.parentPath.parentPath.isTSModuleBlock());
19
21
  };
@@ -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
- print('namespace ');
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.14.0",
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": "^2.0.0",
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",