mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
combine preceding expressions to one
This commit is contained in:
@@ -8,7 +8,6 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
|
||||
const toTemplateLiteralDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_literal);
|
||||
const toStringConcatenationDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_string_concatenation);
|
||||
|
||||
// TODO let a = 45 + 45 + " ee" + 33;
|
||||
// TODO let a = 45 - 45 + " ee" - 33;
|
||||
// TODO let a = tag `aaa`;
|
||||
|
||||
@@ -144,6 +143,19 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
|
||||
let current = nodes[i];
|
||||
let templatePart: TemplateMiddle | TemplateTail;
|
||||
|
||||
if (head.text.length === 0 && i + 1 < nodes.length && !isStringLiteral(nodes[i + 1])) {
|
||||
let binary = createBinary(current as Expression, SyntaxKind.PlusToken, nodes[i + 1] as Expression);
|
||||
current = binary;
|
||||
i++;
|
||||
|
||||
while (i + 1 < nodes.length && !isStringLiteral(nodes[i + 1])) {
|
||||
binary = createBinary(binary, SyntaxKind.PlusToken, nodes[i + 1] as Expression);
|
||||
i++;
|
||||
}
|
||||
|
||||
current = binary;
|
||||
}
|
||||
|
||||
if (i + 1 < nodes.length && isStringLiteral(nodes[i + 1])) {
|
||||
let next = nodes[i + 1] as StringLiteral;
|
||||
let text = next.text;
|
||||
|
||||
Reference in New Issue
Block a user