@@ -668,7 +668,7 @@ const _super = (function (geti, seti) {
668668 // SyntaxKind.TemplateMiddle
669669 // SyntaxKind.TemplateTail
670670 function emitLiteral ( node : LiteralLikeNode ) {
671- const text = getLiteralText ( node , currentSourceFile , languageVersion ) ;
671+ const text = getLiteralTextOfNode ( node ) ;
672672 if ( ( compilerOptions . sourceMap || compilerOptions . inlineSourceMap )
673673 && ( node . kind === SyntaxKind . StringLiteral || isTemplateLiteralKind ( node . kind ) ) ) {
674674 writer . writeLiteral ( text ) ;
@@ -980,7 +980,7 @@ const _super = (function (geti, seti) {
980980 function needsDotDotForPropertyAccess ( expression : Expression ) {
981981 if ( expression . kind === SyntaxKind . NumericLiteral ) {
982982 // check if numeric literal was originally written with a dot
983- const text = getLiteralText ( < LiteralExpression > expression , currentSourceFile , languageVersion ) ;
983+ const text = getLiteralTextOfNode ( < LiteralExpression > expression ) ;
984984 return text . indexOf ( tokenToString ( SyntaxKind . DotToken ) ) < 0 ;
985985 }
986986 else {
@@ -2350,13 +2350,30 @@ const _super = (function (geti, seti) {
23502350 else if ( isIdentifier ( node ) && ( nodeIsSynthesized ( node ) || ! node . parent ) ) {
23512351 return unescapeIdentifier ( node . text ) ;
23522352 }
2353+ else if ( node . kind === SyntaxKind . StringLiteral && ( < StringLiteral > node ) . textSourceNode ) {
2354+ return getTextOfNode ( ( < StringLiteral > node ) . textSourceNode , includeTrivia ) ;
2355+ }
23532356 else if ( isLiteralExpression ( node ) && ( nodeIsSynthesized ( node ) || ! node . parent ) ) {
23542357 return node . text ;
23552358 }
23562359
23572360 return getSourceTextOfNodeFromSourceFile ( currentSourceFile , node , includeTrivia ) ;
23582361 }
23592362
2363+ function getLiteralTextOfNode ( node : LiteralLikeNode ) : string {
2364+ if ( node . kind === SyntaxKind . StringLiteral && ( < StringLiteral > node ) . textSourceNode ) {
2365+ const textSourceNode = ( < StringLiteral > node ) . textSourceNode ;
2366+ if ( isIdentifier ( textSourceNode ) ) {
2367+ return "\"" + escapeNonAsciiCharacters ( escapeString ( getTextOfNode ( textSourceNode ) ) ) + "\"" ;
2368+ }
2369+ else {
2370+ return getLiteralTextOfNode ( textSourceNode ) ;
2371+ }
2372+ }
2373+
2374+ return getLiteralText ( node , currentSourceFile , languageVersion ) ;
2375+ }
2376+
23602377 function tryGetConstEnumValue ( node : Node ) : number {
23612378 if ( compilerOptions . isolatedModules ) {
23622379 return undefined ;
0 commit comments