@putout/printer 15.21.0 → 15.22.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.22.0
2
+
3
+ feature:
4
+ - a295bb3 @putout/printer: TSTemplateLiteralType: add
5
+
6
+ 2025.09.24, v15.21.1
7
+
8
+ fix:
9
+ - 8b47e5e @putout/printer: jsx-element: indent
10
+
1
11
  2025.09.21, v15.21.0
2
12
 
3
13
  feature:
@@ -5,6 +5,7 @@ const {
5
5
  isJSXElement,
6
6
  isJSXExpressionContainer,
7
7
  isFunction,
8
+ isJSXSpreadAttribute,
8
9
  } = types;
9
10
 
10
11
  const isInsideArrow = ({parentPath}) => parentPath.isArrowFunctionExpression();
@@ -69,10 +70,12 @@ function condition(path) {
69
70
  function hasComplexAttribute(path) {
70
71
  const {attributes} = path.node.openingElement;
71
72
 
72
- if (attributes.length >= 4)
73
- return true;
74
-
75
- for (const {value} of attributes) {
73
+ for (const attribute of attributes) {
74
+ const {value} = attribute;
75
+
76
+ if (isJSXSpreadAttribute(attribute))
77
+ return true;
78
+
76
79
  if (!isJSXExpressionContainer(value))
77
80
  continue;
78
81
 
@@ -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
+ };
@@ -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.0",
3
+ "version": "15.22.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",