@putout/printer 2.36.0 → 2.38.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.06.22, v2.38.0
2
+
3
+ feature:
4
+ - 1a9915d @putout/printer: TSMethodSignature: add
5
+
6
+ 2023.06.22, v2.37.0
7
+
8
+ feature:
9
+ - 7eeab91 @putout/printer: TSConstructorSignatureDeclaration: add
10
+
1
11
  2023.06.22, v2.36.0
2
12
 
3
13
  feature:
@@ -198,6 +198,51 @@ module.exports = {
198
198
 
199
199
  print('__typeAnnotation');
200
200
  },
201
+ TSConstructSignatureDeclaration(path, {write, traverse, maybe}) {
202
+ write('new');
203
+ write('(');
204
+
205
+ const params = path.get('parameters');
206
+ const n = params.length - 1;
207
+
208
+ for (const [index, param] of params.entries()) {
209
+ traverse(param);
210
+ maybe.write(index < n, ',');
211
+ maybe.write.space(index < n);
212
+ }
213
+
214
+ write(')');
215
+ const typeAnnotation = path.get('typeAnnotation');
216
+
217
+ if (exists(typeAnnotation)) {
218
+ write(':');
219
+ write.space();
220
+ traverse(typeAnnotation);
221
+ }
222
+ },
223
+ TSMethodSignature(path, {traverse, write, maybe}) {
224
+ traverse(path.get('key'));
225
+ write('(');
226
+
227
+ const params = path.get('parameters');
228
+ const n = params.length - 1;
229
+
230
+ for (const [index, param] of params.entries()) {
231
+ traverse(param);
232
+ maybe.write(index < n, ',');
233
+ maybe.write.space(index < n);
234
+ }
235
+
236
+ write(')');
237
+
238
+ const typeAnnotation = path.get('typeAnnotation');
239
+
240
+ if (exists(typeAnnotation)) {
241
+ write(':');
242
+ write.space();
243
+ traverse(typeAnnotation);
244
+ }
245
+ },
201
246
  TSExpressionWithTypeArguments(path, {print}) {
202
247
  print('__expression');
203
248
  print('__typeParameters');
@@ -216,3 +261,4 @@ module.exports = {
216
261
  }
217
262
  },
218
263
  };
264
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.36.0",
3
+ "version": "2.38.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",