@putout/printer 11.12.0 → 11.13.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,8 @@
1
+ 2024.12.31, v11.13.0
2
+
3
+ feature:
4
+ - 99c7207 @putout/printer: TSUnionType: always add parens when inside TSArrayType (benjamn/recast#1416)
5
+
1
6
  2024.12.25, v11.12.0
2
7
 
3
8
  feature:
@@ -4,10 +4,12 @@ const {types} = require('@putout/babel');
4
4
 
5
5
  const {markAfter} = require('../../mark');
6
6
  const {exists, isNext} = require('../../is');
7
+
7
8
  const {
8
9
  isBlockStatement,
9
10
  isFunctionDeclaration,
10
11
  } = types;
12
+
11
13
  const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
12
14
  const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
13
15
 
@@ -3,14 +3,19 @@
3
3
  const {maybeParens} = require('../../maybe/maybe-parens');
4
4
  const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
5
5
 
6
- module.exports.TSUnionType = maybeParens((path, printer, {maxTypesInOneLine}) => {
7
- const types = path.get('types');
8
- const {length} = types;
9
-
10
- if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
11
- printInOneLine(types, printer);
12
- else
13
- printInCoupleLines(types, printer);
6
+ module.exports.TSUnionType = maybeParens({
7
+ condition: (path) => {
8
+ return path.parentPath.isTSArrayType();
9
+ },
10
+ print: (path, printer, {maxTypesInOneLine}) => {
11
+ const types = path.get('types');
12
+ const {length} = types;
13
+
14
+ if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
15
+ printInOneLine(types, printer);
16
+ else
17
+ printInCoupleLines(types, printer);
18
+ },
14
19
  });
15
20
 
16
21
  function printInOneLine(types, {traverse, write}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.12.0",
3
+ "version": "11.13.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",