Fix tagged templates that consist of a single part

Example:
foo `bar` should compile to foo([“bar”])
This commit is contained in:
Ivo Gabe de Wolff
2015-01-04 20:58:45 +01:00
parent c2d0bf82c4
commit 69d724f554

View File

@@ -2048,7 +2048,12 @@ module ts {
}
function getTemplateLiteralAsStringLiteral(node: LiteralExpression): string {
return '"' + escapeString(node.text) + '"';
if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) {
// Emit tagged template as foo(["string"])
return '["' + escapeString(node.text) + '"]';
} else {
return '"' + escapeString(node.text) + '"';
}
}
function emitTemplateExpression(node: TemplateExpression): void {