@putout/printer 18.23.0 → 18.24.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
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
isIf,
|
|
9
9
|
hasLeadingComment,
|
|
10
10
|
isInsideCall,
|
|
11
|
-
isInsideBody,
|
|
12
11
|
isInsideExpression,
|
|
13
12
|
hasTrailingComment,
|
|
13
|
+
callWithParent,
|
|
14
14
|
} from '#is';
|
|
15
15
|
import {isInsideTuple} from './is-inside-tuple.js';
|
|
16
16
|
import {isLooksLikeChain} from '../member-expression/is-looks-like-chain/index.js';
|
|
@@ -34,9 +34,17 @@ const notLastArgInsideCall = (path) => {
|
|
|
34
34
|
const hasNoProperties = (path) => !path.node.properties.length;
|
|
35
35
|
const hasValue = (path) => path.node.properties[0].value;
|
|
36
36
|
|
|
37
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
isMemberExpression,
|
|
39
|
+
isAssignmentExpression,
|
|
40
|
+
isArrowFunctionExpression,
|
|
41
|
+
} = types;
|
|
38
42
|
|
|
39
|
-
const isParens = createTypeChecker([
|
|
43
|
+
const isParens = createTypeChecker([
|
|
44
|
+
['-', callWithParent(isAssignmentExpression)],
|
|
45
|
+
['+', callWithParent(isArrowFunctionExpression)],
|
|
46
|
+
['+', isInsideExpression],
|
|
47
|
+
]);
|
|
40
48
|
|
|
41
49
|
const callWithCallee = (fn) => (a) => fn(a.get('callee'));
|
|
42
50
|
|
|
@@ -75,6 +83,7 @@ const isIndentBeforeProperty = createTypeChecker([
|
|
|
75
83
|
]);
|
|
76
84
|
|
|
77
85
|
export const ObjectExpression = maybeParens({
|
|
86
|
+
checkParens: false,
|
|
78
87
|
condition: isParens,
|
|
79
88
|
print: (path, printer, semantics) => {
|
|
80
89
|
const {trailingComma} = semantics;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import {types} from '@putout/babel';
|
|
1
2
|
import {maybeParens} from '#maybe-parens';
|
|
3
|
+
import {createTypeChecker} from '#type-checker';
|
|
4
|
+
import {callWithParent} from '#is';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const {
|
|
7
|
+
isCallExpression,
|
|
8
|
+
isVariableDeclarator,
|
|
9
|
+
} = types;
|
|
10
|
+
|
|
11
|
+
const condition = createTypeChecker([
|
|
12
|
+
['-', callWithParent(isCallExpression)],
|
|
13
|
+
['-', callWithParent(isVariableDeclarator)],
|
|
14
|
+
['+: node.expression -> ObjectExpression'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export const TSAsExpression = maybeParens({
|
|
18
|
+
condition,
|
|
19
|
+
print: (path, {print}) => {
|
|
20
|
+
print('__expression');
|
|
21
|
+
print(' as ');
|
|
22
|
+
print('__typeAnnotation');
|
|
23
|
+
},
|
|
7
24
|
});
|
package/package.json
CHANGED