From 73c00ad1e189fbf5b34831e088eba8ac4ce54eb6 Mon Sep 17 00:00:00 2001 From: R-unic Date: Sat, 30 Sep 2023 23:48:47 -0400 Subject: [PATCH] feat: support templated strings --- src/code-generator.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/code-generator.ts b/src/code-generator.ts index cfad39d..0eaf897 100644 --- a/src/code-generator.ts +++ b/src/code-generator.ts @@ -69,7 +69,8 @@ import { CaseBlock, isCaseClause, SetAccessorDeclaration, - RegularExpressionLiteral + RegularExpressionLiteral, + TemplateExpression } from "typescript"; import path from "path"; @@ -918,6 +919,20 @@ export default class CodeGenerator extends StringBuilder { this.append(`/${(node).text}/`); break; } + case SyntaxKind.TemplateExpression: { + const template = node; + this.append('"'); + this.append(template.head.text); + for (const span of template.templateSpans) { + this.append("#{") + this.walk(span.expression); + this.append("}"); + this.append(span.literal.text); + } + + this.append('"'); + break; + } case SyntaxKind.StringLiteral: { this.append(`"${(node).text}"`); break;