From 75179833b352cb1207abfacf8b9e0e880bebf996 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Mon, 23 Sep 2024 21:48:25 +0900 Subject: [PATCH] test: add test case for default imports via whole re-exports --- lib/util/removeUnusedExport.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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', () => {