mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-17 00:34:47 -05:00
remove parentheses also when expression at ending
This commit is contained in:
@@ -164,15 +164,14 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (isParenthesizedExpression(current)) current = current.expression;
|
||||
text = cleanString(text);
|
||||
|
||||
templatePart = i === nodes.length - 1 ? createTemplateTail(text) : createTemplateMiddle(text);
|
||||
}
|
||||
else {
|
||||
templatePart = i === nodes.length - 1 ? createTemplateTail("") : createTemplateMiddle("");
|
||||
}
|
||||
|
||||
if (isParenthesizedExpression(current)) current = current.expression;
|
||||
spans.push(createTemplateSpan(current as Expression, templatePart));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/f/*y*/oobar is " + (42 + 6)
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
"const foo = `foobar is \${42 + 6}`",
|
||||
});
|
||||
Reference in New Issue
Block a user