Skip to content

Commit bb74c60

Browse files
authored
feat(54190): Convert to template string quick fix not available in assignment expressions (#54210)
1 parent 6cbe2e0 commit bb74c60

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/services/refactors/convertStringOrTemplateLiteral.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function getEditsForToTemplateLiteral(context: RefactorContext, node: Node) {
122122
}
123123

124124
function isNotEqualsOperator(node: BinaryExpression) {
125-
return node.operatorToken.kind !== SyntaxKind.EqualsToken;
125+
return !(node.operatorToken.kind === SyntaxKind.EqualsToken || node.operatorToken.kind === SyntaxKind.PlusEqualsToken);
126126
}
127127

128128
function getParentBinaryExpression(expr: Node) {

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExpr.ts renamed to tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExpr1.ts

File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////let b = 1;
4+
////let a = '';
5+
////a += /*a*/'foo' + b/*b*/;
6+
7+
goTo.select("a", "b");
8+
edit.applyRefactor({
9+
refactorName: "Convert to template string",
10+
actionName: "Convert to template string",
11+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
12+
newContent: [
13+
"let b = 1;",
14+
"let a = '';",
15+
"a += `foo${b}`;"
16+
].join("\n")
17+
});

0 commit comments

Comments
 (0)