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