@putout/printer 15.21.1 → 15.23.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/jsx/jsx-element.js +0 -1
- package/lib/tokenize/literals/template-literal.js +5 -17
- package/lib/tokenize/literals/write-template-literal.js +20 -0
- package/lib/tokenize/statements/index.js +2 -0
- package/lib/tokenize/statements/with-statement/with-statement.js +32 -0
- package/lib/tokenize/typescript/index.js +2 -0
- package/lib/tokenize/typescript/ts-template-literal-type/ts-template-literal-type.js +10 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let i = 0;
|
|
3
|
+
const {writeTemplateLiteral} = require('./write-template-literal');
|
|
4
|
+
|
|
5
|
+
module.exports.TemplateLiteral = (path, printer) => {
|
|
7
6
|
const expressions = path.get('expressions');
|
|
7
|
+
const quasis = path.get('quasis');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
write(element.value.raw);
|
|
11
|
-
|
|
12
|
-
const exp = expressions[i++];
|
|
13
|
-
|
|
14
|
-
if (exp) {
|
|
15
|
-
write('${');
|
|
16
|
-
traverse(exp);
|
|
17
|
-
write('}');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
write('`');
|
|
9
|
+
writeTemplateLiteral(quasis, expressions, printer);
|
|
22
10
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.writeTemplateLiteral = (quasis, expressions, {write, traverse}) => {
|
|
4
|
+
write('`');
|
|
5
|
+
let i = 0;
|
|
6
|
+
|
|
7
|
+
for (const element of quasis) {
|
|
8
|
+
write(element.node.value.raw);
|
|
9
|
+
|
|
10
|
+
const exp = expressions[i++];
|
|
11
|
+
|
|
12
|
+
if (exp) {
|
|
13
|
+
write('${');
|
|
14
|
+
traverse(exp);
|
|
15
|
+
write('}');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
write('`');
|
|
20
|
+
};
|
|
@@ -23,6 +23,7 @@ const {Program} = require('./program/program');
|
|
|
23
23
|
const {ContinueStatement} = require('./continue-statement/continue-statement');
|
|
24
24
|
const {LabeledStatement} = require('./labeled-statement/labeled-statement');
|
|
25
25
|
const {EmptyStatement} = require('./empty-statement/empty-statement');
|
|
26
|
+
const {WithStatement} = require('./with-statement/with-statement');
|
|
26
27
|
|
|
27
28
|
const {
|
|
28
29
|
ExportNamespaceSpecifier,
|
|
@@ -59,4 +60,5 @@ module.exports = {
|
|
|
59
60
|
BreakStatement,
|
|
60
61
|
ContinueStatement,
|
|
61
62
|
WhileStatement,
|
|
63
|
+
WithStatement,
|
|
62
64
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {isNext} = require('#is');
|
|
4
|
+
const {markAfter} = require('../../mark');
|
|
5
|
+
|
|
6
|
+
module.exports.WithStatement = {
|
|
7
|
+
print(path, {print, indent}) {
|
|
8
|
+
indent();
|
|
9
|
+
print('with');
|
|
10
|
+
print.space();
|
|
11
|
+
print('(');
|
|
12
|
+
print('__object');
|
|
13
|
+
print(')');
|
|
14
|
+
|
|
15
|
+
if (path.node.body.body) {
|
|
16
|
+
print.space();
|
|
17
|
+
print('__body');
|
|
18
|
+
} else {
|
|
19
|
+
indent.inc();
|
|
20
|
+
print.newline();
|
|
21
|
+
print('__body');
|
|
22
|
+
indent.dec();
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
afterIf(path) {
|
|
26
|
+
return isNext(path);
|
|
27
|
+
},
|
|
28
|
+
after(path, {print}) {
|
|
29
|
+
print.linebreak();
|
|
30
|
+
markAfter(path);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -39,6 +39,7 @@ const {TSInferType} = require('./ts-infer-type/ts-infer-type');
|
|
|
39
39
|
const {TSParameterProperty} = require('./ts-parameter-property/ts-parameter-property');
|
|
40
40
|
const {TSTypeQuery} = require('./ts-type-query/ts-type-query');
|
|
41
41
|
const {TSParenthesizedType} = require('./ts-parenthesized-type/ts-parenthesized-type');
|
|
42
|
+
const {TSTemplateLiteralType} = require('./ts-template-literal-type/ts-template-literal-type');
|
|
42
43
|
|
|
43
44
|
module.exports = {
|
|
44
45
|
TSAsExpression,
|
|
@@ -55,6 +56,7 @@ module.exports = {
|
|
|
55
56
|
TSImportType,
|
|
56
57
|
TSUnionType,
|
|
57
58
|
TSTypeQuery,
|
|
59
|
+
TSTemplateLiteralType,
|
|
58
60
|
TSBigIntKeyword(path, {write}) {
|
|
59
61
|
write('bigint');
|
|
60
62
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {writeTemplateLiteral} = require('../../literals/write-template-literal');
|
|
4
|
+
|
|
5
|
+
module.exports.TSTemplateLiteralType = (path, printer) => {
|
|
6
|
+
const quasis = path.get('quasis');
|
|
7
|
+
const types = path.get('types');
|
|
8
|
+
|
|
9
|
+
writeTemplateLiteral(quasis, types, printer);
|
|
10
|
+
};
|
package/package.json
CHANGED