@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 +11 -0
- package/lib/tokenize/expressions/binary-expression/maybe-inside-binary.js +0 -1
- package/lib/tokenize/expressions/class/class.js +1 -1
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +1 -1
- package/lib/tokenize/typescript/function/ts-declare-function.js +1 -1
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +1 -1
- package/lib/tokenize/typescript/namespace/ts-module-declaration.js +1 -1
- package/lib/tokenize/typescript/type/ts-type-alias-declaration.js +33 -22
- package/package.json +3 -2
- /package/lib/tokenize/expressions/binary-expression/{is-contatenation.js → is-concatenation.js} +0 -0
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:
|
|
@@ -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 '
|
|
3
|
+
import {maybeDeclare} from '#maybe-declare';
|
|
4
4
|
|
|
5
5
|
const isInsideDefaultExport = (path) => {
|
|
6
6
|
return path.parentPath.isExportDefaultDeclaration();
|
|
@@ -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
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
const afterIf = createTypeChecker([
|
|
32
|
+
['-', isStore],
|
|
33
|
+
['-', noNextAndNextParent],
|
|
34
|
+
['+: -> !', isNextType],
|
|
35
|
+
]);
|
|
16
36
|
|
|
17
37
|
export const TSTypeAliasDeclaration = {
|
|
18
|
-
beforeIf
|
|
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 =
|
|
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
|
|
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.
|
|
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-
|
|
73
|
+
"#is-concatenation": "./lib/tokenize/expressions/binary-expression/is-concatenation.js"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@babel/parser": "^7.28.5",
|
/package/lib/tokenize/expressions/binary-expression/{is-contatenation.js → is-concatenation.js}
RENAMED
|
File without changes
|