@putout/printer 18.4.1 → 18.4.3

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,14 @@
1
+ 2026.03.10, v18.4.3
2
+
3
+ fix:
4
+ - ea60557 @putout/printer: is-concatenation
5
+
6
+ 2026.03.10, v18.4.2
7
+
8
+ feature:
9
+ - fffa725 @putout/printer: TSTypeAliasDeclaration: simplify
10
+ - 02c1e2e @putout/printer: maybe-declare
11
+
1
12
  2026.03.10, v18.4.1
2
13
 
3
14
  feature:
@@ -17,4 +17,3 @@ export const maybeInsideBinary = (fn) => (path, printer, semantics) => {
17
17
  if (!insideBinary)
18
18
  indent.dec();
19
19
  };
20
-
@@ -1,12 +1,12 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {markAfter} from '#mark';
3
+ import {maybeDeclare} from '#maybe-declare';
3
4
  import {
4
5
  hasBody,
5
6
  isInsideExport,
6
7
  isInsideTSModuleBlock,
7
8
  isNext,
8
9
  } from '#is';
9
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
10
10
  import {parseComments} from '../../comment/comment.js';
11
11
  import {maybeDecorators} from '../../maybe/maybe-decorators.js';
12
12
 
@@ -2,6 +2,7 @@ import {types} from '@putout/babel';
2
2
  import {hasPrevNewline} from '#mark';
3
3
  import {createTypeChecker} from '#type-checker';
4
4
  import {isConcatenation} from '#is-concatenation';
5
+ import {maybeDeclare} from '#maybe-declare';
5
6
  import {
6
7
  isNext,
7
8
  isCoupleLines,
@@ -19,7 +20,6 @@ import {
19
20
  } from '#is';
20
21
  import {maybeSpaceAfterKeyword} from './maybe-space-after-keyword.js';
21
22
  import {parseLeadingComments} from '../../comment/comment.js';
22
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
23
23
 
24
24
  const {isExportDeclaration} = types;
25
25
 
@@ -1,6 +1,6 @@
1
1
  import {isNext} from '#is';
2
2
  import {printParams} from '#print-params';
3
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
3
+ import {maybeDeclare} from '#maybe-declare';
4
4
 
5
5
  const isInsideDefaultExport = (path) => {
6
6
  return path.parentPath.isExportDefaultDeclaration();
@@ -1,7 +1,7 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {isNext, isNextParent} from '#is';
3
3
  import {markAfter} from '#mark';
4
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
4
+ import {maybeDeclare} from '#maybe-declare';
5
5
 
6
6
  const {
7
7
  isTSTypeAliasDeclaration,
@@ -1,5 +1,5 @@
1
1
  import {isNext} from '#is';
2
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
2
+ import {maybeDeclare} from '#maybe-declare';
3
3
 
4
4
  export const TSModuleDeclaration = {
5
5
  print: maybeDeclare((path, {print}) => {
@@ -1,27 +1,47 @@
1
+ import {types} from '@putout/babel';
2
+ import {markAfter} from '#mark';
3
+ import {maybeDeclare} from '#maybe-declare';
4
+ import {createTypeChecker} from '#type-checker';
1
5
  import {
6
+ callWithNext,
2
7
  isLast,
3
8
  isNext,
4
- isNextParent,
5
9
  } from '#is';
6
- import {markAfter} from '#mark';
7
- import {maybeDeclare} from '../../maybe/maybe-declare.js';
8
10
 
9
- const isNextType = (a) => a
10
- .getNextSibling()
11
- .isTSTypeAliasDeclaration();
11
+ const {
12
+ isTSTypeAliasDeclaration,
13
+ isExportDeclaration,
14
+ isTSConditionalType,
15
+ } = types;
16
+
17
+ const isNextType = callWithNext(isTSTypeAliasDeclaration);
18
+ const isNextExport = callWithNext(isExportDeclaration);
19
+
20
+ const beforeIf = createTypeChecker([
21
+ '+: parentPath -> !ExportNamedDeclaration',
22
+ ]);
23
+
24
+ const isStore = (a, {store}) => store();
25
+
26
+ const noNextAndNextParent = createTypeChecker([
27
+ ['-', isNext],
28
+ ['+: parentPath -> !', isNext],
29
+ ]);
12
30
 
13
- const isNextExport = (a) => a
14
- .getNextSibling()
15
- .isExportDeclaration();
31
+ const afterIf = createTypeChecker([
32
+ ['-', isStore],
33
+ ['-', noNextAndNextParent],
34
+ ['+: -> !', isNextType],
35
+ ]);
16
36
 
17
37
  export const TSTypeAliasDeclaration = {
18
- beforeIf: (path) => !path.parentPath.isExportDeclaration(),
38
+ beforeIf,
19
39
  before: (path, {indent}) => {
20
40
  indent();
21
41
  },
22
42
  print: maybeDeclare((path, {print, maybe, store}) => {
23
43
  const typeAnnotation = path.get('typeAnnotation');
24
- const isConditional = typeAnnotation.isTSConditionalType();
44
+ const isConditional = isTSConditionalType(typeAnnotation);
25
45
 
26
46
  print('type ');
27
47
  print('__id');
@@ -37,20 +57,11 @@ export const TSTypeAliasDeclaration = {
37
57
  const is = store(isLast(path) || isLast(path.parentPath));
38
58
  maybe.print.newline(!is);
39
59
  }),
40
- afterIf(path, {store}) {
41
- const last = store();
42
-
43
- if (last)
44
- return false;
45
-
46
- if (!isNext(path) && !isNextParent(path))
47
- return false;
48
-
49
- return !isNextType(path);
50
- },
60
+ afterIf,
51
61
  after(path, {print, maybe}) {
52
62
  maybe.indent(isNextExport(path));
53
63
  print.newline();
54
64
  markAfter(path);
55
65
  },
56
66
  };
67
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.4.1",
3
+ "version": "18.4.3",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
@@ -63,13 +63,14 @@
63
63
  "#is": "./lib/tokenize/is.js",
64
64
  "#mark": "./lib/tokenize/mark.js",
65
65
  "#maybe-parens": "./lib/tokenize/maybe/maybe-parens.js",
66
+ "#maybe-declare": "./lib/tokenize/maybe/maybe-declare.js",
66
67
  "#print-params": "./lib/tokenize/expressions/function/params.js",
67
68
  "#import-attributes": "./lib/tokenize/statements/import-declaration/import-attribute.js",
68
69
  "#types": "./lib/types.js",
69
70
  "#type-checker": "./lib/tokenize/type-checker/type-checker.js",
70
71
  "#type-checker/instrument": "./lib/tokenize/type-checker/instrument.js",
71
72
  "#type-checker/report": "./lib/tokenize/type-checker/report.js",
72
- "#is-concatenation": "./lib/tokenize/expressions/binary-expression/is-contatenation.js"
73
+ "#is-concatenation": "./lib/tokenize/expressions/binary-expression/is-concatenation.js"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@babel/parser": "^7.28.5",