diff --git a/lib/util/removeUnusedExport.test.ts b/lib/util/removeUnusedExport.test.ts index 6c0cd10..0ca5cd6 100644 --- a/lib/util/removeUnusedExport.test.ts +++ b/lib/util/removeUnusedExport.test.ts @@ -810,6 +810,25 @@ a_namespace.a;`, ); assert.equal(fileService.get('/app/a.ts'), `export const a = 'a';`); }); + + it('should not remove declaration that is used in default import in some other file via a whole-reexport', () => { + const { languageService, fileService } = setup(); + + fileService.set('/app/main.ts', `import a from './a_reexport';`); + fileService.set('/app/a_reexport.ts', `export * from './a';`); + fileService.set('/app/a.ts', `export default 'a';`); + + removeUnusedExport({ + languageService, + fileService, + targetFile: ['/app/a.ts', '/app/a_reexport.ts'], + }); + assert.equal( + fileService.get('/app/a_reexport.ts'), + `export * from './a';`, + ); + assert.equal(fileService.get('/app/a.ts'), `export default 'a';`); + }); }); describe('locally used declaration but not used in any other file', () => {