Skip to content

Commit

Permalink
feat: support templated strings
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Oct 1, 2023
1 parent 722cc52 commit 73c00ad
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/code-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ import {
CaseBlock,
isCaseClause,
SetAccessorDeclaration,
RegularExpressionLiteral
RegularExpressionLiteral,
TemplateExpression
} from "typescript";
import path from "path";

Expand Down Expand Up @@ -918,6 +919,20 @@ export default class CodeGenerator extends StringBuilder {
this.append(`/${(<RegularExpressionLiteral>node).text}/`);
break;
}
case SyntaxKind.TemplateExpression: {
const template = <TemplateExpression>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(`"${(<StringLiteral>node).text}"`);
break;
Expand Down

0 comments on commit 73c00ad

Please sign in to comment.