@putout/printer 18.42.3 → 18.43.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 +9 -1
- package/lib/tokenize/expressions/function/{arrow-function-expression.js → arrow-function-expression/arrow-function-expression.js} +4 -16
- package/lib/tokenize/expressions/function/{class-method.js → class-method/class-method.js} +7 -11
- package/lib/tokenize/expressions/function/{function-declaration.js → function-declaration/function-declaration.js} +4 -11
- package/lib/tokenize/expressions/function/{function-expression.js → function-expression/function-expression.js} +3 -1
- package/lib/tokenize/expressions/function/functions.js +5 -5
- package/lib/tokenize/expressions/function/{object-method.js → object-method/object-method.js} +5 -3
- package/lib/tokenize/expressions/function/print-function-params.js +1 -1
- package/lib/tokenize/expressions/function/return-type.js +10 -0
- package/lib/tokenize/typescript/function/ts-call-signature-declaration.js +1 -1
- package/lib/tokenize/typescript/function/ts-construct-signature-declaration.js +1 -1
- package/lib/tokenize/typescript/function/ts-constructor-type.js +1 -1
- package/lib/tokenize/typescript/function/ts-declare-function.js +1 -1
- package/lib/tokenize/typescript/function/ts-declare-method.js +1 -1
- package/lib/tokenize/typescript/function/ts-function-type.js +1 -1
- package/lib/tokenize/typescript/function/ts-method-signature.js +1 -1
- package/lib/tokenize/typescript/index.js +1 -1
- package/lib/tokenize/typescript/ts-type-parameter-declaration/ts-type-parameter-declaration.js +1 -1
- package/package.json +4 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
2026.09.07, v18.43.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 640e6e16 @putout/printer: return-type
|
|
5
|
+
- 356e5394 @putout/printer: return-type
|
|
6
|
+
- 5cadde8c @putout/printer: FunctionExpression: returnType
|
|
7
|
+
- 45a16f04 @putout/printer: ObjectMethod: printReturnType
|
|
8
|
+
|
|
1
9
|
2026.09.02, v18.42.3
|
|
2
10
|
|
|
3
11
|
fix:
|
|
@@ -891,7 +899,7 @@ fix:
|
|
|
891
899
|
2026.01.18, v17.0.4
|
|
892
900
|
|
|
893
901
|
feature:
|
|
894
|
-
- 06823ba @putout/printer: print-params -> #
|
|
902
|
+
- 06823ba @putout/printer: print-params -> #params
|
|
895
903
|
|
|
896
904
|
2026.01.17, v17.0.3
|
|
897
905
|
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import {exists} from '#is';
|
|
2
1
|
import {maybeParens} from '#maybe-parens';
|
|
3
|
-
import {printParams} from '#
|
|
2
|
+
import {printParams} from '#params';
|
|
3
|
+
import {printReturnType} from '#return-type';
|
|
4
4
|
|
|
5
5
|
export const ArrowFunctionExpression = maybeParens((path, printer, semantics) => {
|
|
6
|
-
const {
|
|
7
|
-
print,
|
|
8
|
-
maybe,
|
|
9
|
-
write,
|
|
10
|
-
traverse,
|
|
11
|
-
} = printer;
|
|
6
|
+
const {print, maybe} = printer;
|
|
12
7
|
|
|
13
8
|
const {async} = path.node;
|
|
14
9
|
|
|
15
10
|
maybe.print(async, 'async ');
|
|
16
11
|
printParams(path, printer, semantics);
|
|
17
|
-
|
|
18
|
-
const returnType = path.get('returnType');
|
|
19
|
-
|
|
20
|
-
if (exists(returnType)) {
|
|
21
|
-
write(':');
|
|
22
|
-
write.space();
|
|
23
|
-
traverse(returnType);
|
|
24
|
-
}
|
|
12
|
+
printReturnType(path, printer);
|
|
25
13
|
|
|
26
14
|
print.space();
|
|
27
15
|
print('=>');
|
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
isNext,
|
|
3
3
|
hasTrailingComment,
|
|
4
4
|
} from '#is';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import {printReturnType} from '#return-type';
|
|
6
|
+
import {maybeDecorators} from '../../../maybe/maybe-decorators.js';
|
|
7
|
+
import {printKey} from '../../object-expression/print-key.js';
|
|
8
|
+
import {printKind} from '../kind.js';
|
|
9
|
+
import {printFunctionParams} from '../print-function-params.js';
|
|
9
10
|
|
|
10
11
|
const noTrailingCommentAndNext = (path) => {
|
|
11
12
|
if (hasTrailingComment(path))
|
|
@@ -18,7 +19,7 @@ export const ClassMethod = {
|
|
|
18
19
|
print: maybeDecorators((path, printer, semantics) => {
|
|
19
20
|
const {print} = printer;
|
|
20
21
|
const {node} = path;
|
|
21
|
-
const {accessibility
|
|
22
|
+
const {accessibility} = node;
|
|
22
23
|
|
|
23
24
|
if (accessibility) {
|
|
24
25
|
print(accessibility);
|
|
@@ -43,12 +44,7 @@ export const ClassMethod = {
|
|
|
43
44
|
printKind(path, printer);
|
|
44
45
|
printKey(path, printer);
|
|
45
46
|
printFunctionParams(path, printer, semantics);
|
|
46
|
-
|
|
47
|
-
if (returnType) {
|
|
48
|
-
print(':');
|
|
49
|
-
print.space();
|
|
50
|
-
print('__returnType');
|
|
51
|
-
}
|
|
47
|
+
printReturnType(path, printer);
|
|
52
48
|
|
|
53
49
|
print.space();
|
|
54
50
|
print('__body');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
|
-
import {printParams} from '#
|
|
2
|
+
import {printParams} from '#params';
|
|
3
3
|
import {markAfter} from '#mark';
|
|
4
4
|
import {
|
|
5
5
|
callWithNext,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
isNextParent,
|
|
8
8
|
} from '#is';
|
|
9
9
|
import {createTypeChecker} from '#type-checker';
|
|
10
|
+
import {printReturnType} from '#return-type';
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
isExpressionStatement,
|
|
@@ -44,11 +45,7 @@ export const FunctionDeclaration = {
|
|
|
44
45
|
print(path, printer, semantics) {
|
|
45
46
|
const {print, maybe} = printer;
|
|
46
47
|
|
|
47
|
-
const {
|
|
48
|
-
async,
|
|
49
|
-
generator,
|
|
50
|
-
returnType,
|
|
51
|
-
} = path.node;
|
|
48
|
+
const {async, generator} = path.node;
|
|
52
49
|
|
|
53
50
|
maybe.print(async, 'async ');
|
|
54
51
|
|
|
@@ -63,11 +60,7 @@ export const FunctionDeclaration = {
|
|
|
63
60
|
|
|
64
61
|
print('__id');
|
|
65
62
|
printParams(path, printer, semantics);
|
|
66
|
-
|
|
67
|
-
if (returnType) {
|
|
68
|
-
print(': ');
|
|
69
|
-
print('__returnType');
|
|
70
|
-
}
|
|
63
|
+
printReturnType(path, printer);
|
|
71
64
|
|
|
72
65
|
print.space();
|
|
73
66
|
print('__body');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {exists} from '#is';
|
|
2
2
|
import {maybeParens} from '#maybe-parens';
|
|
3
|
-
import {printParams} from '#
|
|
3
|
+
import {printParams} from '#params';
|
|
4
|
+
import {printReturnType} from '#return-type';
|
|
4
5
|
|
|
5
6
|
export const FunctionExpression = maybeParens((path, printer, semantics) => {
|
|
6
7
|
const {
|
|
@@ -25,6 +26,7 @@ export const FunctionExpression = maybeParens((path, printer, semantics) => {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
printParams(path, printer, semantics);
|
|
29
|
+
printReturnType(path, printer);
|
|
28
30
|
|
|
29
31
|
print.space();
|
|
30
32
|
print('__body');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {ArrowFunctionExpression} from './arrow-function-expression.js';
|
|
2
|
-
export {FunctionDeclaration} from './function-declaration.js';
|
|
3
|
-
export {ClassPrivateMethod, ClassMethod} from './class-method.js';
|
|
4
|
-
export {ObjectMethod} from './object-method.js';
|
|
5
|
-
export {FunctionExpression} from './function-expression.js';
|
|
1
|
+
export {ArrowFunctionExpression} from './arrow-function-expression/arrow-function-expression.js';
|
|
2
|
+
export {FunctionDeclaration} from './function-declaration/function-declaration.js';
|
|
3
|
+
export {ClassPrivateMethod, ClassMethod} from './class-method/class-method.js';
|
|
4
|
+
export {ObjectMethod} from './object-method/object-method.js';
|
|
5
|
+
export {FunctionExpression} from './function-expression/function-expression.js';
|
package/lib/tokenize/expressions/function/{object-method.js → object-method/object-method.js}
RENAMED
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
isNewlineBetweenSiblings,
|
|
3
3
|
isNext,
|
|
4
4
|
} from '#is';
|
|
5
|
-
import {printParams} from '#
|
|
5
|
+
import {printParams} from '#params';
|
|
6
6
|
import {markAfter} from '#mark';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import {printReturnType} from '#return-type';
|
|
8
|
+
import {printKey} from '../../object-expression/print-key.js';
|
|
9
|
+
import {printKind} from '../kind.js';
|
|
9
10
|
|
|
10
11
|
export const ObjectMethod = {
|
|
11
12
|
beforeIf(path) {
|
|
@@ -21,6 +22,7 @@ export const ObjectMethod = {
|
|
|
21
22
|
printKind(path, printer);
|
|
22
23
|
printKey(path, printer);
|
|
23
24
|
printParams(path, printer, semantics);
|
|
25
|
+
printReturnType(path, printer);
|
|
24
26
|
|
|
25
27
|
print.space();
|
|
26
28
|
print('__body');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.43.0",
|
|
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",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
".": "./lib/printer.js",
|
|
11
11
|
"./is": "./lib/tokenize/is.js",
|
|
12
12
|
"./params": "./lib/tokenize/expressions/function/params.js",
|
|
13
|
+
"./return-type": "./lib/tokenize/expressions/function/return-type.js",
|
|
13
14
|
"./type-checker": "./lib/tokenize/type-checker/type-checker.js",
|
|
14
15
|
"./type-checker/instrument": "./lib/tokenize/type-checker/instrument.js",
|
|
15
16
|
"./type-checker/report": "./lib/tokenize/type-checker/report.js",
|
|
@@ -65,7 +66,8 @@
|
|
|
65
66
|
"#mark": "./lib/tokenize/mark.js",
|
|
66
67
|
"#maybe-parens": "./lib/tokenize/maybe/maybe-parens.js",
|
|
67
68
|
"#maybe-declare": "./lib/tokenize/maybe/maybe-declare.js",
|
|
68
|
-
"#
|
|
69
|
+
"#params": "./lib/tokenize/expressions/function/params.js",
|
|
70
|
+
"#return-type": "./lib/tokenize/expressions/function/return-type.js",
|
|
69
71
|
"#import-attributes": "./lib/tokenize/statements/import-declaration/import-attribute.js",
|
|
70
72
|
"#types": "./lib/types.js",
|
|
71
73
|
"#type-checker": "./lib/tokenize/type-checker/type-checker.js",
|