Closed dheerajvs closed 1 year ago
Thank you for reporting, and for the nice clear example!
I've made a PR that adds this to the i-tests.
But for a fix, need some time to think about ...
Of course if anyone wants to have a go, you are welcome :)
Update: 9.0.4 has improved support for re-exports
, especially involving export *
.
The particular case above is covered with tests.
note: for cases where a file is 'exporting too much' then that is still flagged as an 'unused export'.
For example:
Scenario: export * from ./a1/a2/a.ts - import skipping the mid-level - import from innermost a.ts
Given file "a1/a2/a.ts" is
"""
export const A = 1;
export const A_innermost_unused = 1;
"""
And file "a1/a2/index.ts" is
"""
export * from "./a";
"""
And file "a1/a.ts" is export * from './a';
And file "a1/index.ts" is
"""
// skips the mid-level - imports directly from a1/a2/a.ts NOT the index, so not from an export *
export * from "./a1/a2/a";
export const A_unused = 1;
"""
And file "c.ts" is import { A } from './a1';
When analyzing "tsconfig.json"
Then the result is { "a1/index.ts": ["A_unused"],"a1/a2/index_ts":["A","A_innermost_unused"] }
A
is considered an unused export, when exported from a1/a2/index_ts
.
This seems reasonable, since a1/a2/index.ts
is not really used and its export
or even the whole file, could be removed.
Closing this - as this case is covered with 9.0.4
.
If anyone finds more particular examples, it will be great if you can open more issues, with such examples, then we can continue to improve support ...
thank you for your help!
I get false positives when a symbol is re-exported multiple times.
Repo to reproduce: https://github.com/dheerajvs/ts-unused-exports-test