@@ -71,18 +71,21 @@ namespace ts {
71
71
*
72
72
* @param node The ES6 template literal.
73
73
*/
74
- function getRawLiteral ( node : LiteralLikeNode , currentSourceFile : SourceFile ) {
74
+ function getRawLiteral ( node : TemplateLiteralLikeNode , currentSourceFile : SourceFile ) {
75
75
// Find original source text, since we need to emit the raw strings of the tagged template.
76
76
// The raw strings contain the (escaped) strings of what the user wrote.
77
77
// 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 ) ;
79
81
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
+ }
86
89
87
90
// Newline normalization:
88
91
// ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's
0 commit comments