@putout/printer 2.76.0 → 2.78.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.07.20, v2.78.0
2
+
3
+ feature:
4
+ - 5545104 @putout/printer: TSEnumDeclaration
5
+
6
+ 2023.07.20, v2.77.0
7
+
8
+ feature:
9
+ - 612b039 @putout/printer: TSNonNullExpression
10
+
1
11
  2023.07.15, v2.76.0
2
12
 
3
13
  feature:
@@ -2,6 +2,7 @@
2
2
 
3
3
  const {hasTrailingComment} = require('../is');
4
4
  const {isVariableDeclarator} = require('@babel/types');
5
+
5
6
  const {markBefore} = require('../mark');
6
7
  const {maybeInsideFn} = require('./maybe-inside-fn');
7
8
 
@@ -50,7 +51,7 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
50
51
 
51
52
  print(`/*${value}*/`);
52
53
 
53
- if (path.isStatement() || looksLikeDirective || looksLikeMethod || looksLikeProp || looksLikeSwitchCase) {
54
+ if (path.isStatement() || path.isTSEnumMember() || looksLikeDirective || looksLikeMethod || looksLikeProp || looksLikeSwitchCase) {
54
55
  print.newline();
55
56
  markBefore(path);
56
57
  maybe.indent(looksLikeMethod || looksLikeProp || looksLikeSwitchCase);
@@ -50,4 +50,3 @@ function unaryExpression(path, {maybe, traverse}) {
50
50
  traverse(argPath);
51
51
  maybe.print(!prefix, operator);
52
52
  }
53
-
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ module.exports.TSEnumDeclaration = (path, {print, traverse, indent}) => {
4
+ print('const ');
5
+ print('enum ');
6
+ print('__id');
7
+ print(' ');
8
+ print('{');
9
+
10
+ indent.inc();
11
+ print.newline();
12
+
13
+ for (const member of path.get('members')) {
14
+ traverse(member);
15
+ print(',');
16
+ print.newline();
17
+ }
18
+
19
+ indent.dec();
20
+ print('}');
21
+ };
22
+
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports.TSEnumMember = (path, {print, indent}) => {
4
+ indent();
5
+ print('__id');
6
+ print.space();
7
+ print('=');
8
+ print.space();
9
+ print('__initializer');
10
+ };
@@ -20,6 +20,8 @@ const {TSIntersectionType} = require('./ts-intersection-type');
20
20
  const {TSPropertySignature} = require('./ts-property-signature');
21
21
  const {TSFunctionType} = require('./ts-function-type');
22
22
  const {printParams} = require('../expressions/functions/params');
23
+ const {TSEnumDeclaration} = require('./enum/ts-enum-declaration');
24
+ const {TSEnumMember} = require('./enum/ts-enum-member');
23
25
 
24
26
  module.exports = {
25
27
  TSAsExpression,
@@ -235,4 +237,10 @@ module.exports = {
235
237
  print(' is ');
236
238
  print('__typeAnnotation');
237
239
  },
240
+ TSNonNullExpression(path, {print}) {
241
+ print('__expression');
242
+ print('!');
243
+ },
244
+ TSEnumDeclaration,
245
+ TSEnumMember,
238
246
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.76.0",
3
+ "version": "2.78.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",