@@ -71,18 +71,21 @@ namespace ts {
7171 *
7272 * @param node The ES6 template literal.
7373 */
74- function getRawLiteral ( node : LiteralLikeNode , currentSourceFile : SourceFile ) {
74+ function getRawLiteral ( node : TemplateLiteralLikeNode , currentSourceFile : SourceFile ) {
7575 // Find original source text, since we need to emit the raw strings of the tagged template.
7676 // The raw strings contain the (escaped) strings of what the user wrote.
7777 // Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
78- let text = getSourceTextOfNodeFromSourceFile ( currentSourceFile , node ) ;
78+ let text = node . rawText ;
79+ if ( text === undefined ) {
80+ text = getSourceTextOfNodeFromSourceFile ( currentSourceFile , node ) ;
7981
80- // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
81- // thus we need to remove those characters.
82- // First template piece starts with "`", others with " }"
83- // Last template piece ends with "`", others with "${"
84- const isLast = node . kind === SyntaxKind . NoSubstitutionTemplateLiteral || node . kind === SyntaxKind . TemplateTail ;
85- text = text . substring ( 1 , text . length - ( isLast ? 1 : 2 ) ) ;
82+ // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
83+ // thus we need to remove those characters.
84+ // First template piece starts with "`", others with " }"
85+ // Last template piece ends with "`", others with "${"
86+ const isLast = node . kind === SyntaxKind . NoSubstitutionTemplateLiteral || node . kind === SyntaxKind . TemplateTail ;
87+ text = text . substring ( 1 , text . length - ( isLast ? 1 : 2 ) ) ;
88+ }
8689
8790 // Newline normalization:
8891 // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's
0 commit comments