@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
@@ -1,3 +1,8 @@
1
+ 2026.06.27, v18.24.0
2
+
3
+ feature:
4
+ - 524967f6 @putout/printer: ObjectExpression inside TSAsExpression
5
+
1
6
  2026.06.26, v18.23.0
2
7
 
3
8
  feature:
@@ -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 {isMemberExpression} = types;
37
+ const {
38
+ isMemberExpression,
39
+ isAssignmentExpression,
40
+ isArrowFunctionExpression,
41
+ } = types;
38
42
 
39
- const isParens = createTypeChecker([isInsideBody, isInsideExpression]);
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
- export const TSAsExpression = maybeParens((path, {print}) => {
4
- print('__expression');
5
- print(' as ');
6
- print('__typeAnnotation');
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.23.0",
3
+ "version": "18.24.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",