also looking at this
fix(bundle): leave template literal text alone when renaming identifiers
#3131
3 files
+108
-3
| @@ -31,4 +31,18 @@ describe('renameIdentifiers', () => { | ||
| 31 | 31 | 'declare function f(options: Options_1, o: { Options: string, x?: Options_1 }): Ns.Options | \'Options\';', |
| 32 | 32 | ) |
| 33 | 33 | }) |
| 34 | ||
| 35 | it('leaves template literal text alone and renames inside its placeholders', () => { | |
| 36 | const renames = new Map([['Options', 'Options_1']]) | |
| 37 | const text = [ | |
| 38 | 'type A = `Options` | `// Options` | `\\`Options` | `\\${Options}` | Options;', | |
| 39 | 'type B = `${Options}-Options` | `a${`Options-${Options}`}b` | `${{ Options: 1 } extends Options ? \'x\' : \'y\'}`;', | |
| 40 | 'type C = Options;', | |
| 41 | ].join('\n') | |
| 42 | expect(renameIdentifiers(text, renames)).toBe([ | |
| 43 | 'type A = `Options` | `// Options` | `\\`Options` | `\\${Options}` | Options_1;', | |
| 44 | 'type B = `${Options_1}-Options` | `a${`Options-${Options_1}`}b` | `${{ Options: 1 } extends Options_1 ? \'x\' : \'y\'}`;', | |
| 45 | 'type C = Options_1;', | |
| 46 | ].join('\n')) | |
| 47 | }) | |
| 34 | 48 | }) |