Skip to content

Commit 74e3cd7

Browse files
committed
remove parentheses also when expression at ending
1 parent 7d9e8f4 commit 74e3cd7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/services/refactors/convertStringOrTemplateLiteral.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,14 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
164164
i++;
165165
}
166166

167-
if (isParenthesizedExpression(current)) current = current.expression;
168167
text = cleanString(text);
169-
170168
templatePart = i === nodes.length - 1 ? createTemplateTail(text) : createTemplateMiddle(text);
171169
}
172170
else {
173171
templatePart = i === nodes.length - 1 ? createTemplateTail("") : createTemplateMiddle("");
174172
}
175173

174+
if (isParenthesizedExpression(current)) current = current.expression;
176175
spans.push(createTemplateSpan(current as Expression, templatePart));
177176
}
178177

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//// const foo = "/*x*/f/*y*/oobar is " + (42 + 6)
4+
5+
goTo.select("x", "y");
6+
edit.applyRefactor({
7+
refactorName: "Convert string concatenation or template literal",
8+
actionName: "Convert to template literal",
9+
actionDescription: "Convert to template literal",
10+
newContent:
11+
"const foo = `foobar is \${42 + 6}`",
12+
});

0 commit comments

Comments
 (0)