@putout/printer 10.1.1 → 10.3.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
|
+
2024.11.04, v10.3.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ed9efd1 @putout/printer: TSTypleType: formatting
|
|
5
|
+
|
|
6
|
+
2024.10.29, v10.2.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 329ca16 @putout/printer: TSTypeLiteral: one inside TSTypeParameterInstantiation: no newline
|
|
10
|
+
|
|
1
11
|
2024.10.29, v10.1.1
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -5,16 +5,33 @@ module.exports.TSTupleType = (path, {write, traverse, indent, maybe}) => {
|
|
|
5
5
|
|
|
6
6
|
write('[');
|
|
7
7
|
indent.inc();
|
|
8
|
-
maybe.write.newline(elementTypes.length);
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const isSame = isSameType(elementTypes);
|
|
10
|
+
maybe.write.newline(isSame && elementTypes.length);
|
|
11
|
+
const n = elementTypes.length - 1;
|
|
12
|
+
|
|
13
|
+
for (const [i, elementType] of elementTypes.entries()) {
|
|
14
|
+
maybe.indent(isSame);
|
|
12
15
|
traverse(elementType);
|
|
13
|
-
write(',');
|
|
14
|
-
write.newline();
|
|
16
|
+
maybe.write(i < n || isSame, ',');
|
|
17
|
+
maybe.write.newline(isSame);
|
|
18
|
+
maybe.write.space(i < n && !isSame);
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
indent.dec();
|
|
18
|
-
indent();
|
|
22
|
+
maybe.indent(isSame && elementTypes.length);
|
|
19
23
|
write(']');
|
|
20
24
|
};
|
|
25
|
+
|
|
26
|
+
function isSameType(array) {
|
|
27
|
+
let type;
|
|
28
|
+
|
|
29
|
+
for (const current of array) {
|
|
30
|
+
if (type && current.type !== type)
|
|
31
|
+
return false;
|
|
32
|
+
|
|
33
|
+
({type} = current);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
@@ -27,5 +27,8 @@ module.exports.TSTypeLiteral = (path, {indent, traverse, write}) => {
|
|
|
27
27
|
function isNewline(path) {
|
|
28
28
|
const members = path.get('members');
|
|
29
29
|
|
|
30
|
+
if (members.length === 1 && path.parentPath.isTSTypeParameterInstantiation())
|
|
31
|
+
return false;
|
|
32
|
+
|
|
30
33
|
return members.length && members[0].node.typeAnnotation;
|
|
31
34
|
}
|
package/package.json
CHANGED