@putout/printer 10.6.0 → 10.8.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 +10 -0
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +4 -2
- package/lib/tokenize/typescript/index.js +3 -6
- package/lib/tokenize/typescript/ts-parameter-property/ts-parameter-property.js +36 -0
- package/package.json +1 -1
- /package/lib/tokenize/typescript/ts-infer-type/{ts-infert-type.js → ts-infer-type.js} +0 -0
package/ChangeLog
CHANGED
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
} = require('../../is');
|
|
17
17
|
|
|
18
18
|
const {moreThenMaxPropertiesInOneLine} = require('./more-then-max-properties-in-one-line');
|
|
19
|
+
const isInsideFn = (path) => path.parentPath.isFunction();
|
|
19
20
|
|
|
20
21
|
const {maybeTypeAnnotation} = require('../../maybe/maybe-type-annotation');
|
|
21
22
|
const {moreThenMaxPropertiesLengthInOneLine} = require('./more-then-max-properties-length-in-one-line');
|
|
@@ -65,7 +66,8 @@ module.exports.ObjectPattern = {
|
|
|
65
66
|
|
|
66
67
|
const hasObject = n && hasObjectPattern(properties);
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
const notInsideFn = !isInsideFn(path);
|
|
70
|
+
maybe.print.newline(is && notInsideFn);
|
|
69
71
|
|
|
70
72
|
for (const [i, property] of properties.entries()) {
|
|
71
73
|
if (property.isRestElement()) {
|
|
@@ -88,7 +90,7 @@ module.exports.ObjectPattern = {
|
|
|
88
90
|
valuePath,
|
|
89
91
|
});
|
|
90
92
|
|
|
91
|
-
maybe.indent(is);
|
|
93
|
+
maybe.indent(is && notInsideFn);
|
|
92
94
|
maybe.print.breakline(couple);
|
|
93
95
|
|
|
94
96
|
printKey(property, printer);
|
|
@@ -39,7 +39,8 @@ const {maybePrintTypeAnnotation} = require('../maybe/maybe-type-annotation');
|
|
|
39
39
|
const {TSImportType} = require('./ts-import-type');
|
|
40
40
|
const {TSExportAssignment} = require('./ts-export-assignment/ts-export-assignment');
|
|
41
41
|
const {TSTypeReference} = require('./ts-type-reference/ts-type-reference');
|
|
42
|
-
const {TSInferType} = require('./ts-infer-type/ts-
|
|
42
|
+
const {TSInferType} = require('./ts-infer-type/ts-infer-type');
|
|
43
|
+
const {TSParameterProperty} = require('./ts-parameter-property/ts-parameter-property');
|
|
43
44
|
|
|
44
45
|
module.exports = {
|
|
45
46
|
TSAsExpression,
|
|
@@ -173,14 +174,10 @@ module.exports = {
|
|
|
173
174
|
print('.');
|
|
174
175
|
print('__right');
|
|
175
176
|
},
|
|
176
|
-
TSParameterProperty(path, {write, print}) {
|
|
177
|
-
write(path.node.accessibility);
|
|
178
|
-
write.space();
|
|
179
|
-
print('__parameter');
|
|
180
|
-
},
|
|
181
177
|
TSTypeAnnotation(path, {print}) {
|
|
182
178
|
print('__typeAnnotation');
|
|
183
179
|
},
|
|
180
|
+
TSParameterProperty,
|
|
184
181
|
TSConstructSignatureDeclaration,
|
|
185
182
|
TSIndexSignature(path, printer) {
|
|
186
183
|
const {print} = printer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSParameterProperty = (path, {print, maybe}) => {
|
|
4
|
+
const {
|
|
5
|
+
decorators,
|
|
6
|
+
readonly,
|
|
7
|
+
accessibility,
|
|
8
|
+
} = path.node;
|
|
9
|
+
|
|
10
|
+
const decoratorsLength = decorators?.length;
|
|
11
|
+
|
|
12
|
+
maybe.print.breakline(decoratorsLength);
|
|
13
|
+
|
|
14
|
+
if (decorators)
|
|
15
|
+
for (const decorator of path.get('decorators')) {
|
|
16
|
+
print.indent();
|
|
17
|
+
print(decorator);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
maybe.print.breakline(decoratorsLength);
|
|
21
|
+
maybe.indent(decoratorsLength);
|
|
22
|
+
|
|
23
|
+
if (accessibility) {
|
|
24
|
+
print(accessibility);
|
|
25
|
+
print.space();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (readonly) {
|
|
29
|
+
print('readonly');
|
|
30
|
+
print.space();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
print('__parameter');
|
|
34
|
+
maybe.print(decoratorsLength, ',');
|
|
35
|
+
maybe.print.breakline(decoratorsLength);
|
|
36
|
+
};
|
package/package.json
CHANGED
|
File without changes
|