@@ -40,6 +40,17 @@ namespace ts {
4040 return ( file : SourceFile ) => file ;
4141 }
4242
43+ function replaceIdentifiersNamedOldNameWithNewName2 ( context : TransformationContext ) {
44+ const visitor : Visitor = ( node ) => {
45+ if ( isIdentifier ( node ) && node . text === "oldName" ) {
46+ return createIdentifier ( "newName" ) ;
47+ }
48+
49+ return visitEachChild ( node , visitor , context ) ;
50+ }
51+ return ( node : SourceFile ) => visitNode ( node , visitor ) ;
52+ }
53+
4354 function transformSourceFile ( sourceText : string , transformers : TransformerFactory < SourceFile > [ ] ) {
4455 const transformed = transform ( createSourceFile ( "source.ts" , sourceText , ScriptTarget . ES2015 ) , transformers ) ;
4556 const printer = createPrinter ( { newLine : NewLineKind . CarriageReturnLineFeed } , {
@@ -81,6 +92,18 @@ namespace ts {
8192 } ) . outputText ;
8293 } ) ;
8394
95+ testBaseline ( "issue27854" , ( ) => {
96+ return transpileModule ( `oldName<{ a: string; }>\` ... \`;` , {
97+ transformers : {
98+ before : [ replaceIdentifiersNamedOldNameWithNewName2 ]
99+ } ,
100+ compilerOptions : {
101+ newLine : NewLineKind . CarriageReturnLineFeed ,
102+ target : ts . ScriptTarget . Latest
103+ }
104+ } ) . outputText ;
105+ } ) ;
106+
84107 testBaseline ( "rewrittenNamespace" , ( ) => {
85108 return transpileModule ( `namespace Reflect { const x = 1; }` , {
86109 transformers : {
0 commit comments