@putout/printer 2.83.0 → 2.85.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.25, v2.85.0
2
+
3
+ feature:
4
+ - c28e82a @putout/printer: TSConstructorType: add (coderaiser/putout#149)
5
+
6
+ 2023.07.25, v2.84.0
7
+
8
+ feature:
9
+ - 5febcd6 @putout/printer: ClassMethod: accessibility
10
+
1
11
  2023.07.24, v2.83.0
2
12
 
3
13
  feature:
@@ -11,6 +11,8 @@ const ClassMethod = {
11
11
  kind,
12
12
  computed,
13
13
  generator,
14
+ accessibility,
15
+ returnType,
14
16
  } = path.node;
15
17
 
16
18
  const isConstructor = kind === 'constructor';
@@ -20,6 +22,11 @@ const ClassMethod = {
20
22
  maybe.print(isConstructor, kind);
21
23
  maybe.print(generator, '*');
22
24
 
25
+ if (accessibility) {
26
+ print(accessibility);
27
+ print(' ');
28
+ }
29
+
23
30
  if (isMethod) {
24
31
  maybe.print(computed, '[');
25
32
  print('__key');
@@ -34,6 +41,12 @@ const ClassMethod = {
34
41
 
35
42
  printParams(path, printer, semantics);
36
43
 
44
+ if (returnType) {
45
+ print(':');
46
+ print.space();
47
+ print('__returnType');
48
+ }
49
+
37
50
  print.space();
38
51
  print('__body');
39
52
  },
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {markAfter} = require('../../mark');
4
- const {exists} = require('../../is');
4
+ const {exists, isNext} = require('../../is');
5
5
 
6
6
  const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
7
7
  const isInsideNestedBody = ({parentPath}) => {
@@ -60,14 +60,7 @@ module.exports.IfStatement = {
60
60
  indent.dec();
61
61
  }
62
62
  },
63
- afterIf: (path) => {
64
- const next = path.getNextSibling();
65
-
66
- if (!exists(next))
67
- return false;
68
-
69
- return !next.isReturnStatement();
70
- },
63
+ afterSatisfy: () => [isNext],
71
64
  after: (path, {print}) => {
72
65
  print.linebreak();
73
66
  markAfter(path);
@@ -25,6 +25,7 @@ const {TSEnumDeclaration} = require('./enum/ts-enum-declaration');
25
25
  const {TSEnumMember} = require('./enum/ts-enum-member');
26
26
  const {TSTupleType} = require('./tuple/ts-tuple-type');
27
27
  const {TSNamedTupleMember} = require('./tuple/ts-named-tuple-member');
28
+ const {TSConstructorType} = require('./ts-constructor-type');
28
29
 
29
30
  module.exports = {
30
31
  TSAsExpression,
@@ -251,4 +252,5 @@ module.exports = {
251
252
  },
252
253
  TSDeclareMethod,
253
254
  TSNamedTupleMember,
255
+ TSConstructorType,
254
256
  };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const {printParams} = require('../expressions/functions/params');
4
+
5
+ module.exports.TSConstructorType = (path, printer, semantics) => {
6
+ const {print} = printer;
7
+
8
+ print('new');
9
+ print(' ');
10
+
11
+ printParams(path, printer, semantics, {
12
+ params: path.get('parameters'),
13
+ });
14
+
15
+ print.space();
16
+ print('=>');
17
+ print.space();
18
+ print('__typeAnnotation');
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.83.0",
3
+ "version": "2.85.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",