@putout/printer 15.21.1 → 15.23.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
+ 2025.10.01, v15.23.0
2
+
3
+ feature:
4
+ - be1ec5d @putout/printer: WithStatement: add
5
+
6
+ 2025.10.01, v15.22.0
7
+
8
+ feature:
9
+ - a295bb3 @putout/printer: TSTemplateLiteralType: add
10
+
1
11
  2025.09.24, v15.21.1
2
12
 
3
13
  fix:
@@ -98,4 +98,3 @@ function isNeedIndent(path) {
98
98
 
99
99
  return insideJSX || insideFn && insideCall;
100
100
  }
101
-
@@ -1,22 +1,10 @@
1
1
  'use strict';
2
2
 
3
- module.exports.TemplateLiteral = (path, {write, traverse}) => {
4
- write('`');
5
-
6
- let i = 0;
3
+ const {writeTemplateLiteral} = require('./write-template-literal');
4
+
5
+ module.exports.TemplateLiteral = (path, printer) => {
7
6
  const expressions = path.get('expressions');
7
+ const quasis = path.get('quasis');
8
8
 
9
- for (const element of path.node.quasis) {
10
- write(element.value.raw);
11
-
12
- const exp = expressions[i++];
13
-
14
- if (exp) {
15
- write('${');
16
- traverse(exp);
17
- write('}');
18
- }
19
- }
20
-
21
- write('`');
9
+ writeTemplateLiteral(quasis, expressions, printer);
22
10
  };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ module.exports.writeTemplateLiteral = (quasis, expressions, {write, traverse}) => {
4
+ write('`');
5
+ let i = 0;
6
+
7
+ for (const element of quasis) {
8
+ write(element.node.value.raw);
9
+
10
+ const exp = expressions[i++];
11
+
12
+ if (exp) {
13
+ write('${');
14
+ traverse(exp);
15
+ write('}');
16
+ }
17
+ }
18
+
19
+ write('`');
20
+ };
@@ -23,6 +23,7 @@ const {Program} = require('./program/program');
23
23
  const {ContinueStatement} = require('./continue-statement/continue-statement');
24
24
  const {LabeledStatement} = require('./labeled-statement/labeled-statement');
25
25
  const {EmptyStatement} = require('./empty-statement/empty-statement');
26
+ const {WithStatement} = require('./with-statement/with-statement');
26
27
 
27
28
  const {
28
29
  ExportNamespaceSpecifier,
@@ -59,4 +60,5 @@ module.exports = {
59
60
  BreakStatement,
60
61
  ContinueStatement,
61
62
  WhileStatement,
63
+ WithStatement,
62
64
  };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const {isNext} = require('#is');
4
+ const {markAfter} = require('../../mark');
5
+
6
+ module.exports.WithStatement = {
7
+ print(path, {print, indent}) {
8
+ indent();
9
+ print('with');
10
+ print.space();
11
+ print('(');
12
+ print('__object');
13
+ print(')');
14
+
15
+ if (path.node.body.body) {
16
+ print.space();
17
+ print('__body');
18
+ } else {
19
+ indent.inc();
20
+ print.newline();
21
+ print('__body');
22
+ indent.dec();
23
+ }
24
+ },
25
+ afterIf(path) {
26
+ return isNext(path);
27
+ },
28
+ after(path, {print}) {
29
+ print.linebreak();
30
+ markAfter(path);
31
+ },
32
+ };
@@ -39,6 +39,7 @@ const {TSInferType} = require('./ts-infer-type/ts-infer-type');
39
39
  const {TSParameterProperty} = require('./ts-parameter-property/ts-parameter-property');
40
40
  const {TSTypeQuery} = require('./ts-type-query/ts-type-query');
41
41
  const {TSParenthesizedType} = require('./ts-parenthesized-type/ts-parenthesized-type');
42
+ const {TSTemplateLiteralType} = require('./ts-template-literal-type/ts-template-literal-type');
42
43
 
43
44
  module.exports = {
44
45
  TSAsExpression,
@@ -55,6 +56,7 @@ module.exports = {
55
56
  TSImportType,
56
57
  TSUnionType,
57
58
  TSTypeQuery,
59
+ TSTemplateLiteralType,
58
60
  TSBigIntKeyword(path, {write}) {
59
61
  write('bigint');
60
62
  },
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const {writeTemplateLiteral} = require('../../literals/write-template-literal');
4
+
5
+ module.exports.TSTemplateLiteralType = (path, printer) => {
6
+ const quasis = path.get('quasis');
7
+ const types = path.get('types');
8
+
9
+ writeTemplateLiteral(quasis, types, printer);
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.21.1",
3
+ "version": "15.23.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",