@putout/printer 1.95.0 → 1.97.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,13 @@
|
|
|
1
|
+
2023.05.11, v1.97.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- b0aa0ff @putout/printer: TSAsExpression inside MemberExpression: improve support
|
|
5
|
+
|
|
6
|
+
2023.05.11, v1.96.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 9b7297f @putout/printer: improve support of LogicalExpression inside AwaitExpression
|
|
10
|
+
|
|
1
11
|
2023.05.11, v1.95.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const BinaryExpression = {
|
|
4
|
+
condition(path) {
|
|
5
|
+
return path.parentPath.isAwaitExpression();
|
|
6
|
+
},
|
|
7
|
+
before(path, {print}) {
|
|
8
|
+
print('(');
|
|
9
|
+
},
|
|
10
|
+
print(path, {write, traverse, maybe}) {
|
|
11
|
+
const left = path.get('left');
|
|
12
|
+
const right = path.get('right');
|
|
13
|
+
const isLeft = isLogical(path, left);
|
|
14
|
+
const isRight = isLogical(path, right);
|
|
15
|
+
|
|
16
|
+
maybe.write(isLeft, '(');
|
|
17
|
+
traverse(left);
|
|
18
|
+
maybe.write(isLeft, ')');
|
|
19
|
+
write.space();
|
|
20
|
+
write(path.node.operator);
|
|
21
|
+
write.space();
|
|
22
|
+
maybe.write(isRight, '(');
|
|
23
|
+
traverse(right);
|
|
24
|
+
maybe.write(isRight, ')');
|
|
25
|
+
},
|
|
26
|
+
after(path, {print}) {
|
|
27
|
+
print(')');
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
3
31
|
module.exports.BinaryExpression = BinaryExpression;
|
|
4
32
|
module.exports.LogicalExpression = BinaryExpression;
|
|
5
33
|
|
|
@@ -11,20 +39,3 @@ const isLogical = (main, path) => {
|
|
|
11
39
|
|
|
12
40
|
return main.node.operator !== path.node.operator;
|
|
13
41
|
};
|
|
14
|
-
|
|
15
|
-
function BinaryExpression(path, {write, traverse, maybe}) {
|
|
16
|
-
const left = path.get('left');
|
|
17
|
-
const right = path.get('right');
|
|
18
|
-
const isLeft = isLogical(path, left);
|
|
19
|
-
const isRight = isLogical(path, right);
|
|
20
|
-
|
|
21
|
-
maybe.write(isLeft, '(');
|
|
22
|
-
traverse(left);
|
|
23
|
-
maybe.write(isLeft, ')');
|
|
24
|
-
write.space();
|
|
25
|
-
write(path.node.operator);
|
|
26
|
-
write.space();
|
|
27
|
-
maybe.write(isRight, '(');
|
|
28
|
-
traverse(right);
|
|
29
|
-
maybe.write(isRight, ')');
|
|
30
|
-
}
|
|
@@ -41,7 +41,10 @@ module.exports.MemberExpression = (path, {print, maybe, traverse}) => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
module.exports.OptionalMemberExpression = (path, {print, maybe}) => {
|
|
44
|
-
const {
|
|
44
|
+
const {
|
|
45
|
+
computed,
|
|
46
|
+
optional,
|
|
47
|
+
} = path.node;
|
|
45
48
|
print('__object');
|
|
46
49
|
maybe.print(optional, '?');
|
|
47
50
|
print('.');
|
|
@@ -80,4 +83,3 @@ function likeChain(path) {
|
|
|
80
83
|
|
|
81
84
|
return calls.length > 1;
|
|
82
85
|
}
|
|
83
|
-
|
|
@@ -14,8 +14,10 @@ const {
|
|
|
14
14
|
} = require('./ts-module-declaration');
|
|
15
15
|
|
|
16
16
|
const {TSInterfaceDeclaration} = require('./ts-interface-declaration');
|
|
17
|
+
const {TSAsExpression} = require('./ts-as-expression');
|
|
17
18
|
|
|
18
19
|
module.exports = {
|
|
20
|
+
TSAsExpression,
|
|
19
21
|
TSTypeLiteral,
|
|
20
22
|
TSTypeAliasDeclaration,
|
|
21
23
|
TSTypeParameter,
|
|
@@ -108,11 +110,6 @@ module.exports = {
|
|
|
108
110
|
print('>');
|
|
109
111
|
print('__expression');
|
|
110
112
|
},
|
|
111
|
-
TSAsExpression(path, {print}) {
|
|
112
|
-
print('__expression');
|
|
113
|
-
print(' as ');
|
|
114
|
-
print('__typeAnnotation');
|
|
115
|
-
},
|
|
116
113
|
TSParenthesizedType(path, {print}) {
|
|
117
114
|
print('(');
|
|
118
115
|
print('__typeAnnotation');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSAsExpression = {
|
|
4
|
+
condition(path) {
|
|
5
|
+
return path.parentPath.isMemberExpression();
|
|
6
|
+
},
|
|
7
|
+
before(path, {write}) {
|
|
8
|
+
write('(');
|
|
9
|
+
},
|
|
10
|
+
print(path, {print}) {
|
|
11
|
+
print('__expression');
|
|
12
|
+
print(' as ');
|
|
13
|
+
print('__typeAnnotation');
|
|
14
|
+
},
|
|
15
|
+
after(path, {write}) {
|
|
16
|
+
write(')');
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
package/package.json
CHANGED