@putout/printer 18.33.0 → 18.34.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 +5 -0
- package/README.md +11 -0
- package/lib/tokenize/typescript/index.js +2 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ actually `traverse(path.get('right'))` shortened to simplify read and process.
|
|
|
82
82
|
Here is how you can override `AssignmentPattern`:
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
|
+
const {print} = printer;
|
|
85
86
|
const ast = parse('const {a = 5} = b');
|
|
86
87
|
|
|
87
88
|
print(ast, {
|
|
@@ -222,6 +223,8 @@ Used in previous example `print` can be used for a couple purposes:
|
|
|
222
223
|
- to write `node` when `string` started with `__`;
|
|
223
224
|
|
|
224
225
|
```js
|
|
226
|
+
const {print} = printer;
|
|
227
|
+
|
|
225
228
|
print(ast, {
|
|
226
229
|
visitors: {
|
|
227
230
|
AssignmentPattern(path, {print, maybe}) {
|
|
@@ -239,6 +242,8 @@ When you need some condition use `maybe`. For example, to add newline only when
|
|
|
239
242
|
can use `maybe.write.newline(condition)`:
|
|
240
243
|
|
|
241
244
|
```js
|
|
245
|
+
const {print} = printer;
|
|
246
|
+
|
|
242
247
|
print(ast, {
|
|
243
248
|
visitors: {
|
|
244
249
|
AssignmentPattern(path, {write, maybe}) {
|
|
@@ -255,6 +260,8 @@ print(ast, {
|
|
|
255
260
|
When you going to output string you can use low-level function `write`:
|
|
256
261
|
|
|
257
262
|
```js
|
|
263
|
+
const {print} = printer;
|
|
264
|
+
|
|
258
265
|
print(ast, {
|
|
259
266
|
visitors: {
|
|
260
267
|
BlockStatement(path, {write}) {
|
|
@@ -270,6 +277,8 @@ When you need to add indentation use `indent`, for example when you output body,
|
|
|
270
277
|
you need to increment indentation, and then decrement it back:
|
|
271
278
|
|
|
272
279
|
```js
|
|
280
|
+
const {print} = printer;
|
|
281
|
+
|
|
273
282
|
print(ast, {
|
|
274
283
|
visitors: {
|
|
275
284
|
BlockStatement(path, {write, indent}) {
|
|
@@ -289,6 +298,8 @@ print(ast, {
|
|
|
289
298
|
When you need to traverse node path, you can use `traverse`:
|
|
290
299
|
|
|
291
300
|
```js
|
|
301
|
+
const {print} = printer;
|
|
302
|
+
|
|
292
303
|
print(ast, {
|
|
293
304
|
visitors: {
|
|
294
305
|
AssignmentExpression(path, {traverse}) {
|
|
@@ -140,6 +140,8 @@ export const TSClassImplements = (path, {print}) => {
|
|
|
140
140
|
print('__typeArguments');
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
export const TSExpressionWithTypeArguments = TSClassImplements;
|
|
144
|
+
|
|
143
145
|
export const TSInterfaceHeritage = (path, {print}) => {
|
|
144
146
|
print('__expression');
|
|
145
147
|
print('__typeArguments');
|
package/package.json
CHANGED