Skip to content

Commit 6fe4663

Browse files
committed
combine preceding expressions to one
1 parent 76ce1c6 commit 6fe4663

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/services/refactors/convertStringOrTemplateLiteral.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
88
const toTemplateLiteralDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_literal);
99
const toStringConcatenationDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_string_concatenation);
1010

11-
// TODO let a = 45 + 45 + " ee" + 33;
1211
// TODO let a = 45 - 45 + " ee" - 33;
1312
// TODO let a = tag `aaa`;
1413

@@ -144,6 +143,19 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
144143
let current = nodes[i];
145144
let templatePart: TemplateMiddle | TemplateTail;
146145

146+
if (head.text.length === 0 && i + 1 < nodes.length && !isStringLiteral(nodes[i + 1])) {
147+
let binary = createBinary(current as Expression, SyntaxKind.PlusToken, nodes[i + 1] as Expression);
148+
current = binary;
149+
i++;
150+
151+
while (i + 1 < nodes.length && !isStringLiteral(nodes[i + 1])) {
152+
binary = createBinary(binary, SyntaxKind.PlusToken, nodes[i + 1] as Expression);
153+
i++;
154+
}
155+
156+
current = binary;
157+
}
158+
147159
if (i + 1 < nodes.length && isStringLiteral(nodes[i + 1])) {
148160
let next = nodes[i + 1] as StringLiteral;
149161
let text = next.text;

0 commit comments

Comments
 (0)