@putout/printer 1.65.0 → 1.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.04.21, v1.67.0
2
+
3
+ feature:
4
+ - fd645f6 @putout/printer add support of "for export type *"
5
+
6
+ 2023.04.21, v1.66.0
7
+
8
+ feature:
9
+ - 31a3e52 @putout/printer: add support for const type parameters
10
+
1
11
  2023.04.21, v1.65.0
2
12
 
3
13
  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');
@@ -14,10 +14,27 @@ module.exports.ExportSpecifier = (path, {print}) => {
14
14
  }
15
15
  };
16
16
 
17
+ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
18
+ print(' * as ');
19
+ print('__exported');
20
+ };
21
+
17
22
  module.exports.ExportNamedDeclaration = (path, {print, traverse, write, indent}) => {
23
+ const {exportKind} = path.node;
18
24
  const specifiers = path.get('specifiers');
25
+
19
26
  write('export ');
20
27
 
28
+ if (exportKind === 'type' && specifiers.length) {
29
+ print('type');
30
+ print(specifiers[0]);
31
+ print(' from ');
32
+ print('__source');
33
+ print(';');
34
+
35
+ return;
36
+ }
37
+
21
38
  if (specifiers.length) {
22
39
  write('{');
23
40
  indent.inc();
@@ -16,7 +16,11 @@ const {SwitchStatement} = require('./switch-statement');
16
16
  const {ForInStatement} = require('./for-in-statement');
17
17
  const {ExportDefaultDeclaration} = require('./export-default-declaration');
18
18
  const {BreakStatement} = require('./break-statement');
19
- const {ExportSpecifier} = exportDeclarations;
19
+
20
+ const {
21
+ ExportNamespaceSpecifier,
22
+ ExportSpecifier,
23
+ } = exportDeclarations;
20
24
 
21
25
  module.exports = {
22
26
  ...importDeclarations,
@@ -24,6 +28,7 @@ module.exports = {
24
28
  BlockStatement,
25
29
  ExpressionStatement,
26
30
  ExportSpecifier,
31
+ ExportNamespaceSpecifier,
27
32
  ExportDefaultDeclaration,
28
33
  VariableDeclaration,
29
34
  IfStatement,
@@ -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.67.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",