@putout/printer 1.65.0 → 1.66.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.04.21, v1.66.0
2
+
3
+ feature:
4
+ - 31a3e52 @putout/printer: add support for const type parameters
5
+
1
6
  2023.04.21, v1.65.0
2
7
 
3
8
  feature:
@@ -11,6 +11,7 @@ module.exports.FunctionDeclaration = {
11
11
 
12
12
  print('function ');
13
13
  print('__id');
14
+ print('__typeParameters');
14
15
  print('(');
15
16
 
16
17
  const params = path.get('params');
@@ -5,10 +5,12 @@ const {TSTypeLiteral} = require('./ts-type-literal');
5
5
  const {TSTypeAliasDeclaration} = require('./ts-type-alias-declaration');
6
6
  const {TSMappedType} = require('./ts-mapped-type');
7
7
  const {TSConditionalType} = require('./ts-conditional-type');
8
+ const {TSTypeParameter} = require('./ts-type-parameter');
8
9
 
9
10
  module.exports = {
10
11
  TSTypeLiteral,
11
12
  TSTypeAliasDeclaration,
13
+ TSTypeParameter,
12
14
  TSMappedType,
13
15
  TSConditionalType,
14
16
  TSNeverKeyword(path, {write}) {
@@ -64,27 +66,6 @@ module.exports = {
64
66
  print('__elementType');
65
67
  print('[]');
66
68
  },
67
- TSTypeParameter(path, {write, traverse}) {
68
- const constraint = path.get('constraint');
69
-
70
- if (path.node.in)
71
- write('in ');
72
- else if (path.node.out)
73
- write('out ');
74
-
75
- write(path.node.name);
76
-
77
- if (!exists(constraint))
78
- return;
79
-
80
- if (constraint.isTSTypeOperator()) {
81
- write(' in ');
82
- } else {
83
- write(' extends ');
84
- }
85
-
86
- traverse(constraint);
87
- },
88
69
  TSTypeOperator(path, {write, print}) {
89
70
  const {operator} = path.node;
90
71
  write(`${operator} `);
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ const {exists} = require('../is');
4
+
5
+ module.exports.TSTypeParameter = (path, {write, traverse}) => {
6
+ const constraint = path.get('constraint');
7
+
8
+ if (path.node.in)
9
+ write('in ');
10
+ else if (path.node.out)
11
+ write('out ');
12
+ else if (path.node.const)
13
+ write('const ');
14
+
15
+ write(path.node.name);
16
+
17
+ if (!exists(constraint))
18
+ return;
19
+
20
+ if (constraint.isTSTypeOperator()) {
21
+ write(' in ');
22
+ } else {
23
+ write(' extends ');
24
+ }
25
+
26
+ traverse(constraint);
27
+ };
28
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.65.0",
3
+ "version": "1.66.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",