@putout/printer 2.65.0 → 2.67.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,13 @@
1
+ 2023.07.10, v2.67.0
2
+
3
+ feature:
4
+ - de5a124 @putout/printer: TSModuleDeclaration inside ExportDeclaration
5
+
6
+ 2023.07.10, v2.66.0
7
+
8
+ feature:
9
+ - 77088cb @putout/printer: TSDeclareFunction: params
10
+
1
11
  2023.07.10, v2.65.0
2
12
 
3
13
  feature:
@@ -8,10 +8,9 @@ const {
8
8
  } = require('../../is');
9
9
 
10
10
  const {markAfter, isMarkedAfter} = require('../../mark');
11
-
12
11
  const {isExportNamespaceSpecifier} = require('@babel/types');
13
-
14
12
  const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
13
+ const isInsideNamespace = (path) => path.parentPath.isTSModuleBlock();
15
14
 
16
15
  const options = {
17
16
  exports: {
@@ -83,6 +82,7 @@ module.exports.ExportNamedDeclaration = {
83
82
  }
84
83
 
85
84
  indent.dec();
85
+ indent();
86
86
  write('}');
87
87
 
88
88
  const source = path.get('source');
@@ -93,7 +93,7 @@ module.exports.ExportNamedDeclaration = {
93
93
  }
94
94
 
95
95
  write(';');
96
- maybe.write.newline(isNext(path));
96
+ maybe.write.newline(isNext(path) || isInsideNamespace(path));
97
97
 
98
98
  return;
99
99
  }
@@ -1,24 +1,23 @@
1
1
  'use strict';
2
2
 
3
- module.exports.TSDeclareFunction = (path, {print, maybe}) => {
3
+ const {printParams} = require('../expressions/functions/params');
4
+ const {isNext} = require('../is');
5
+
6
+ const notInsideExport = (path) => !path.parentPath.isExportDeclaration();
7
+
8
+ module.exports.TSDeclareFunction = (path, printer, semantics) => {
9
+ const {print, maybe} = printer;
4
10
  const {declare} = path.node;
5
11
 
6
12
  maybe.print(declare, 'declare ');
7
13
  print('function ');
8
14
  print('__id');
9
- print('(');
10
15
 
11
- const params = path.get('params');
12
- const n = params.length - 1;
16
+ printParams(path, printer, semantics);
13
17
 
14
- for (const [i, param] of params.entries()) {
15
- print(param);
16
- maybe.print(i < n, ', ');
17
- }
18
-
19
- print(')');
20
18
  print(':');
21
19
  print.space();
22
-
23
20
  print('__returnType');
21
+ maybe.print(notInsideExport(path), ';');
22
+ maybe.print.newline(isNext(path));
24
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.65.0",
3
+ "version": "2.67.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",