Skip to content

Commit

Permalink
test: add test case for default imports via whole re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
kazushisan committed Sep 23, 2024
1 parent 3a78f8c commit 7517983
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/util/removeUnusedExport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 7517983

Please sign in to comment.