@putout/printer 8.41.0 → 8.43.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
+ 2024.06.06, v8.43.0
2
+
3
+ feature:
4
+ - e48fb76 @putout/printer: TSPropertySignature: computed (coderaiser/putout#206)
5
+
6
+ 2024.06.05, v8.42.0
7
+
8
+ feature:
9
+ - d33926d @putout/printer: improve support of TSPropertySignature inside of TSTypeLiteral (coderaiser/putout#206)
10
+
1
11
  2024.06.03, v8.41.0
2
12
 
3
13
  feature:
@@ -18,6 +18,7 @@ const classVisitor = maybeDecorators((path, printer, semantics) => {
18
18
  abstract,
19
19
  superClass,
20
20
  } = path.node;
21
+
21
22
  const {
22
23
  print,
23
24
  indent,
@@ -18,7 +18,7 @@ const {TSInterfaceDeclaration} = require('./interface/ts-interface-declaration')
18
18
  const {TSAsExpression} = require('./ts-as-expression');
19
19
  const {TSInterfaceBody} = require('./interface/ts-interface-body');
20
20
  const {TSIntersectionType} = require('./ts-intersection-type');
21
- const {TSPropertySignature} = require('./ts-property-signature');
21
+ const {TSPropertySignature} = require('./ts-property-signature/ts-property-signature');
22
22
  const {TSFunctionType} = require('./function/ts-function-type');
23
23
  const {printParams} = require('../expressions/function/params');
24
24
  const {TSEnumDeclaration} = require('./enum/ts-enum-declaration');
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const {maybePrintTypeAnnotation} = require('../../maybe/maybe-type-annotation');
4
+
5
+ const {
6
+ hasTrailingComment,
7
+ isNext,
8
+ } = require('../../is');
9
+
10
+ module.exports.TSPropertySignature = (path, printer) => {
11
+ const {
12
+ print,
13
+ maybe,
14
+ write,
15
+ } = printer;
16
+
17
+ const {
18
+ computed,
19
+ optional,
20
+ readonly,
21
+ } = path.node;
22
+
23
+ maybe.print(readonly, 'readonly ');
24
+ maybe.print(computed, '[');
25
+ print('__key');
26
+ maybe.print(computed, ']');
27
+ maybe.print(optional, '?');
28
+
29
+ maybePrintTypeAnnotation(path, printer);
30
+
31
+ if (!isTSTypeLiteralWithOneMember(path)) {
32
+ write(';');
33
+ write.newline();
34
+ }
35
+
36
+ if (isNext(path) && hasTrailingComment(path))
37
+ write.newline();
38
+ };
39
+
40
+ function isTSTypeLiteralWithOneMember({parentPath}) {
41
+ if (!parentPath.parentPath.isTSTypeParameterInstantiation())
42
+ return false;
43
+
44
+ return parentPath.node.members.length === 1;
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.41.0",
3
+ "version": "8.43.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",
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- const {maybePrintTypeAnnotation} = require('../maybe/maybe-type-annotation');
4
-
5
- const {
6
- hasTrailingComment,
7
- isNext,
8
- } = require('../is');
9
-
10
- module.exports.TSPropertySignature = (path, printer) => {
11
- const {
12
- print,
13
- maybe,
14
- write,
15
- } = printer;
16
-
17
- const {optional, readonly} = path.node;
18
-
19
- maybe.print(readonly, 'readonly ');
20
- print('__key');
21
- maybe.print(optional, '?');
22
-
23
- maybePrintTypeAnnotation(path, printer);
24
-
25
- if (!path.parentPath.parentPath.isTSTypeParameterInstantiation()) {
26
- write(';');
27
- write.newline();
28
- }
29
-
30
- if (isNext(path) && hasTrailingComment(path))
31
- write.newline();
32
- };