@putout/printer 5.25.0 → 5.27.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.18, v5.27.0
2
+
3
+ feature:
4
+ - f799814 @putout/printer: ClassDeclaration: supertTypeParameters
5
+ - 36192f7 @putout/printer: ClassMethod: typeParameters
6
+
7
+ 2023.10.18, v5.26.0
8
+
9
+ feature:
10
+ - 801a8f1 @putout/printer: TSDeclareFunction: typeParameters
11
+
1
12
  2023.10.18, v5.25.0
2
13
 
3
14
  feature:
@@ -37,6 +37,7 @@ const classVisitor = maybeDecorators((path, printer, semantics) => {
37
37
  maybe.print(id && !node.implements, ' ');
38
38
  print('extends ');
39
39
  print('__superClass');
40
+ print('__superTypeParameters');
40
41
  }
41
42
 
42
43
  print.space();
@@ -50,6 +50,7 @@ const ClassMethod = {
50
50
  print('__key');
51
51
  }
52
52
 
53
+ print('__typeParameters');
53
54
  printParams(path, printer, semantics);
54
55
 
55
56
  if (returnType) {
@@ -2,33 +2,39 @@
2
2
 
3
3
  const {printParams} = require('../../expressions/function/params');
4
4
  const {isNext} = require('../../is');
5
+ const {maybeDeclare} = require('../../maybe/maybe-declare');
5
6
 
6
- const isInsideExport = (path) => {
7
+ const isInsideDefaultExport = (path) => {
7
8
  return path.parentPath.isExportDefaultDeclaration();
8
9
  };
9
10
 
10
- module.exports.TSDeclareFunction = (path, printer, semantics) => {
11
- const {
12
- print,
13
- maybe,
14
- indent,
15
- } = printer;
16
-
17
- const {declare} = path.node;
18
-
19
- indent();
20
- maybe.print(declare, 'declare ');
21
- print('function ');
22
- print('__id');
23
-
24
- printParams(path, printer, semantics);
25
-
26
- print(':');
27
- print.space();
28
- print('__returnType');
29
-
30
- if (!isInsideExport(path)) {
11
+ const isInsideNamedExport = (path) => {
12
+ return path.parentPath.isExportNamedDeclaration();
13
+ };
14
+
15
+ module.exports.TSDeclareFunction = {
16
+ beforeIf: (path) => !isInsideNamedExport(path),
17
+ before: (path, {indent}) => {
18
+ indent();
19
+ },
20
+ print: maybeDeclare((path, printer, semantics) => {
21
+ const {print} = printer;
22
+
23
+ print('function ');
24
+ print('__id');
25
+ print('__typeParameters');
26
+
27
+ printParams(path, printer, semantics);
28
+
29
+ print(':');
30
+ print.space();
31
+ print('__returnType');
32
+ }),
33
+ afterIf: (path) => !isInsideDefaultExport(path),
34
+ after: (path, {print}) => {
31
35
  print(';');
32
- maybe.print.newline(isNext(path) || isNext(path.parentPath));
33
- }
36
+
37
+ if (isNext(path) || isNext(path.parentPath) || isInsideNamedExport(path))
38
+ print.newline();
39
+ },
34
40
  };
@@ -18,7 +18,9 @@ module.exports.TSInterfaceDeclaration = {
18
18
 
19
19
  if (node.extends) {
20
20
  print(' extends ');
21
- path.get('extends').map(print);
21
+ path
22
+ .get('extends')
23
+ .map(print);
22
24
  }
23
25
 
24
26
  print('__typeParameters');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "5.25.0",
3
+ "version": "5.27.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",