@putout/printer 2.70.0 → 2.71.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,8 @@
1
+ 2023.07.14, v2.71.0
2
+
3
+ feature:
4
+ - 71bf28d @putout/printer: TSTypeParameterInstantiation: couple params (coderaiser/putout#147)
5
+
1
6
  2023.07.12, v2.70.0
2
7
 
3
8
  feature:
@@ -3,12 +3,17 @@
3
3
  const {parseComments} = require('../../comment/comment');
4
4
 
5
5
  module.exports.printParams = (path, printer, semantics, customization = {}) => {
6
- const {params = path.get('params')} = customization;
6
+ const {
7
+ params = path.get('params'),
8
+ braceOpen = '(',
9
+ braceClose = ')',
10
+ } = customization;
7
11
 
8
12
  const {print, traverse} = printer;
9
13
 
10
14
  printBraceOpen(path, {
11
15
  print,
16
+ braceOpen,
12
17
  });
13
18
 
14
19
  parseComments(path, printer, semantics);
@@ -28,21 +33,22 @@ module.exports.printParams = (path, printer, semantics, customization = {}) => {
28
33
 
29
34
  printBraceClose(path, {
30
35
  print,
36
+ braceClose,
31
37
  });
32
38
  };
33
39
 
34
- function printBraceOpen(path, {print}) {
40
+ function printBraceOpen(path, {print, braceOpen}) {
35
41
  if (isOneArgArrow(path))
36
42
  return print.roundBraceOpen();
37
43
 
38
- return print('(');
44
+ return print(braceOpen);
39
45
  }
40
46
 
41
- function printBraceClose(path, {print}) {
47
+ function printBraceClose(path, {print, braceClose}) {
42
48
  if (isOneArgArrow(path))
43
49
  return print.roundBraceClose();
44
50
 
45
- print(')');
51
+ print(braceClose);
46
52
  }
47
53
 
48
54
  function isOneArgArrow(path) {
@@ -19,6 +19,7 @@ const {TSInterfaceBody} = require('./interface/ts-interface-body');
19
19
  const {TSIntersectionType} = require('./ts-intersection-type');
20
20
  const {TSPropertySignature} = require('./ts-property-signature');
21
21
  const {TSFunctionType} = require('./ts-function-type');
22
+ const {printParams} = require('../expressions/functions/params');
22
23
 
23
24
  module.exports = {
24
25
  TSAsExpression,
@@ -77,23 +78,17 @@ module.exports = {
77
78
  print('...');
78
79
  print('__typeAnnotation');
79
80
  },
80
- TSTypeParameterDeclaration(path, {print}) {
81
- print('<');
82
-
83
- path
84
- .get('params')
85
- .forEach(print);
86
-
87
- print('>');
88
- },
89
- TSTypeParameterInstantiation(path, {print}) {
90
- print('<');
91
-
92
- path
93
- .get('params')
94
- .forEach(print);
95
-
96
- print('>');
81
+ TSTypeParameterDeclaration(path, printer, semantics) {
82
+ printParams(path, printer, semantics, {
83
+ braceOpen: '<',
84
+ braceClose: '>',
85
+ });
86
+ },
87
+ TSTypeParameterInstantiation(path, printer, semantics) {
88
+ printParams(path, printer, semantics, {
89
+ braceOpen: '<',
90
+ braceClose: '>',
91
+ });
97
92
  },
98
93
  TSTypeReference(path, {print}) {
99
94
  print('__typeName');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.70.0",
3
+ "version": "2.71.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",