fix(47853): Convert to template string issue (#47976)

This commit is contained in:
Zzzen
2022-03-01 02:40:48 +08:00
committed by GitHub
parent 0043abe982
commit 41b981c998
2 changed files with 12 additions and 1 deletions

View File

@@ -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));
});