mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
fix(47853): Convert to template string issue (#47976)
This commit is contained in:
parent
0043abe982
commit
41b981c998
@ -215,7 +215,7 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
|
||||
const isLastSpan = index === currentNode.templateSpans.length - 1;
|
||||
const text = span.literal.text + (isLastSpan ? subsequentText : "");
|
||||
const rawText = getRawTextOfTemplate(span.literal) + (isLastSpan ? rawSubsequentText : "");
|
||||
return factory.createTemplateSpan(span.expression, isLast
|
||||
return factory.createTemplateSpan(span.expression, isLast && isLastSpan
|
||||
? factory.createTemplateTail(text, rawText)
|
||||
: factory.createTemplateMiddle(text, rawText));
|
||||
});
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////fetch(/*start*/process.env.API_URL + `/foo/bar?id=${id}&token=${token}`/*end*/);
|
||||
|
||||
goTo.select("start", "end");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert to template string",
|
||||
actionName: "Convert to template string",
|
||||
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
|
||||
newContent: "fetch(`${process.env.API_URL}/foo/bar?id=${id}&token=${token}`);",
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user