@putout/printer 2.84.0 → 2.86.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.26, v2.86.0
2
+
3
+ feature:
4
+ - 42a28c1 @putout/printer: static-property (coderaiser/putout#159)
5
+
6
+ 2023.07.25, v2.85.0
7
+
8
+ feature:
9
+ - c28e82a @putout/printer: TSConstructorType: add (coderaiser/putout#149)
10
+
1
11
  2023.07.25, v2.84.0
2
12
 
3
13
  feature:
@@ -3,20 +3,15 @@
3
3
  const {exists} = require('../../is');
4
4
 
5
5
  module.exports.ClassProperty = ClassProperty;
6
-
7
- module.exports.ClassPrivateProperty = (path, {print}) => {
8
- ClassProperty(path, {
9
- print,
10
- });
11
- };
12
-
6
+ module.exports.ClassPrivateProperty = ClassProperty;
13
7
  module.exports.PrivateName = (path, {print}) => {
14
8
  print('#');
15
9
  print('__id');
16
10
  };
17
11
 
18
- function ClassProperty(path, {print}) {
19
- const {accessibility} = path.node;
12
+ function ClassProperty(path, {print, maybe}) {
13
+ const {node} = path;
14
+ const {accessibility, optional} = node;
20
15
  const value = path.get('value');
21
16
  const typeAnnotation = path.get('typeAnnotation');
22
17
 
@@ -25,7 +20,13 @@ function ClassProperty(path, {print}) {
25
20
  print(' ');
26
21
  }
27
22
 
23
+ if (node.static) {
24
+ print('static');
25
+ print(' ');
26
+ }
27
+
28
28
  print('__key');
29
+ maybe.print(optional, '?');
29
30
 
30
31
  if (exists(typeAnnotation)) {
31
32
  print(':');
@@ -43,3 +44,4 @@ function ClassProperty(path, {print}) {
43
44
  print(';');
44
45
  print.newline();
45
46
  }
47
+
@@ -6,14 +6,14 @@ const {printParams} = require('./params');
6
6
  const ClassMethod = {
7
7
  print(path, printer, semantics) {
8
8
  const {print, maybe} = printer;
9
-
9
+ const {node} = path;
10
10
  const {
11
11
  kind,
12
12
  computed,
13
13
  generator,
14
14
  accessibility,
15
15
  returnType,
16
- } = path.node;
16
+ } = node;
17
17
 
18
18
  const isConstructor = kind === 'constructor';
19
19
  const isMethod = kind === 'method';
@@ -27,6 +27,11 @@ const ClassMethod = {
27
27
  print(' ');
28
28
  }
29
29
 
30
+ if (node.static) {
31
+ print('static');
32
+ print(' ');
33
+ }
34
+
30
35
  if (isMethod) {
31
36
  maybe.print(computed, '[');
32
37
  print('__key');
@@ -60,12 +60,9 @@ module.exports.IfStatement = {
60
60
  indent.dec();
61
61
  }
62
62
  },
63
- afterSatisfy: () => [
64
- isNext,
65
- ],
63
+ afterSatisfy: () => [isNext],
66
64
  after: (path, {print}) => {
67
65
  print.linebreak();
68
66
  markAfter(path);
69
67
  },
70
68
  };
71
-
@@ -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.84.0",
3
+ "version": "2.86.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",