@putout/printer 11.1.1 → 11.2.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,10 @@
1
+ 2024.12.12, v11.2.0
2
+
3
+ feature:
4
+ - 523cd24 @putout/printer: TSUnionType: newlines inside of functions
5
+ - 1f99cbb @putout/printer: @putout/plugin-minify v9.0.0
6
+ - 2c507b1 @putout/printer: TSTypeQuery: maybe parens
7
+
1
8
  2024.12.11, v11.1.1
2
9
 
3
10
  fix:
@@ -37,6 +37,7 @@ const {TSExportAssignment} = require('./ts-export-assignment/ts-export-assignmen
37
37
  const {TSTypeReference} = require('./ts-type-reference/ts-type-reference');
38
38
  const {TSInferType} = require('./ts-infer-type/ts-infer-type');
39
39
  const {TSParameterProperty} = require('./ts-parameter-property/ts-parameter-property');
40
+ const {TSTypeQuery} = require('./ts-type-query/ts-type-query');
40
41
 
41
42
  module.exports = {
42
43
  TSAsExpression,
@@ -52,6 +53,7 @@ module.exports = {
52
53
  TSIntersectionType,
53
54
  TSImportType,
54
55
  TSUnionType,
56
+ TSTypeQuery,
55
57
  TSBigIntKeyword(path, {write}) {
56
58
  write('bigint');
57
59
  },
@@ -61,10 +63,6 @@ module.exports = {
61
63
  TSSymbolKeyword(path, {write}) {
62
64
  write('symbol');
63
65
  },
64
- TSTypeQuery(path, {print}) {
65
- print('typeof ');
66
- print('__exprName');
67
- },
68
66
  TSNeverKeyword(path, {write}) {
69
67
  write('never');
70
68
  },
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const {maybeParens} = require('../../maybe/maybe-parens');
4
+
5
+ module.exports.TSTypeQuery = maybeParens((path, {print}) => {
6
+ print('typeof ');
7
+ print('__exprName');
8
+ });
@@ -5,12 +5,15 @@ const {
5
5
  maybeParenClose,
6
6
  } = require('../../expressions/unary-expression/parens');
7
7
 
8
- module.exports.TSUnionType = (path, printer, semantics) => {
8
+ const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
9
+
10
+ module.exports.TSUnionType = (path, printer, {maxTypesInOneLine}) => {
9
11
  const types = path.get('types');
12
+ const {length} = types;
10
13
 
11
14
  maybeParenOpen(path, printer);
12
15
 
13
- if (types.length <= semantics.maxTypesInOneLine)
16
+ if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
14
17
  printInOneLine(types, printer);
15
18
  else
16
19
  printInCoupleLines(types, printer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.1.1",
3
+ "version": "11.2.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",
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "devDependencies": {
54
54
  "@putout/eslint": "^3.5.0",
55
- "@putout/plugin-minify": "^8.0.0",
55
+ "@putout/plugin-minify": "^9.0.0",
56
56
  "@putout/plugin-printer": "^3.0.0",
57
57
  "@putout/plugin-promises": "^15.0.0",
58
58
  "@putout/plugin-react-hook-form": "^4.0.0",