@@ -2088,7 +2088,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
2088
2088
// SyntaxKind.TemplateMiddle
2089
2089
// SyntaxKind.TemplateTail
2090
2090
function emitLiteral ( node : LiteralLikeNode , jsxAttributeEscape : boolean ) {
2091
- const text = getLiteralTextOfNode ( node , printerOptions . neverAsciiEscape , jsxAttributeEscape ) ;
2091
+ const text = getLiteralTextOfNode ( node , /*sourceFile*/ undefined , printerOptions . neverAsciiEscape , jsxAttributeEscape ) ;
2092
2092
if (
2093
2093
( printerOptions . sourceMap || printerOptions . inlineSourceMap )
2094
2094
&& ( node . kind === SyntaxKind . StringLiteral || isTemplateLiteralKind ( node . kind ) )
@@ -2641,7 +2641,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
2641
2641
expression = skipPartiallyEmittedExpressions ( expression ) ;
2642
2642
if ( isNumericLiteral ( expression ) ) {
2643
2643
// check if numeric literal is a decimal literal that was originally written with a dot
2644
- const text = getLiteralTextOfNode ( expression as LiteralExpression , /*neverAsciiEscape*/ true , /*jsxAttributeEscape*/ false ) ;
2644
+ const text = getLiteralTextOfNode ( expression as LiteralExpression , /*sourceFile*/ undefined , /* neverAsciiEscape*/ true , /*jsxAttributeEscape*/ false ) ;
2645
2645
// If the number will be printed verbatim and it doesn't already contain a dot or an exponent indicator, add one
2646
2646
// if the expression doesn't have any comments that will be emitted.
2647
2647
return ! ( expression . numericLiteralFlags & TokenFlags . WithSpecifier )
@@ -5169,7 +5169,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
5169
5169
return getSourceTextOfNodeFromSourceFile ( sourceFile , node , includeTrivia ) ;
5170
5170
}
5171
5171
5172
- function getLiteralTextOfNode ( node : LiteralLikeNode , neverAsciiEscape : boolean | undefined , jsxAttributeEscape : boolean ) : string {
5172
+ function getLiteralTextOfNode ( node : LiteralLikeNode , sourceFile = currentSourceFile , neverAsciiEscape : boolean | undefined , jsxAttributeEscape : boolean ) : string {
5173
5173
if ( node . kind === SyntaxKind . StringLiteral && ( node as StringLiteral ) . textSourceNode ) {
5174
5174
const textSourceNode = ( node as StringLiteral ) . textSourceNode ! ;
5175
5175
if ( isIdentifier ( textSourceNode ) || isPrivateIdentifier ( textSourceNode ) || isNumericLiteral ( textSourceNode ) || isJsxNamespacedName ( textSourceNode ) ) {
@@ -5179,7 +5179,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
5179
5179
`"${ escapeNonAsciiString ( text ) } "` ;
5180
5180
}
5181
5181
else {
5182
- return getLiteralTextOfNode ( textSourceNode , neverAsciiEscape , jsxAttributeEscape ) ;
5182
+ return getLiteralTextOfNode ( textSourceNode , getSourceFileOfNode ( textSourceNode ) , neverAsciiEscape , jsxAttributeEscape ) ;
5183
5183
}
5184
5184
}
5185
5185
@@ -5188,7 +5188,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
5188
5188
| ( printerOptions . terminateUnterminatedLiterals ? GetLiteralTextFlags . TerminateUnterminatedLiterals : 0 )
5189
5189
| ( printerOptions . target && printerOptions . target >= ScriptTarget . ES2021 ? GetLiteralTextFlags . AllowNumericSeparator : 0 ) ;
5190
5190
5191
- return getLiteralText ( node , currentSourceFile , flags ) ;
5191
+ return getLiteralText ( node , sourceFile , flags ) ;
5192
5192
}
5193
5193
5194
5194
/**
0 commit comments