Closed ilyin371 closed 1 year ago
Thank you for reporting it
hi @ilyin371 - I cannot repro this issue.
I pushed a branch where I try the above, but it seems to work OK for me!
branch = scratch/path-alias-issue-154
cd example/with-paths
node ../../bin/ts-unused-exports tsconfig.json
OUTPUT:
.../example/with-paths/math.ts: add1
(calculations.ts does NOT appear as unused)
@ilyin371 is there something about your tsconfig.json
file ? :thinking:
My tsconfig.json
is:
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"noEmit": true,
"noImplicitAny": true,
"strictNullChecks": true,
"moduleResolution": "node",
"paths": {
"utils": ["utils/src"],
"utils/*": ["utils/src/*"]
}
}
}
same issue here, I can confirm it's due to path aliases. i can create a reproducible environment later today.
PS: awesome project
@kevinoliveira if you can post example or even better make a fork with working example, that would be great!
@mrseanryan i hope this can be useful https://github.com/kevinoliveira/ts-unused-exports-issue-154-example
cheers @kevinoliveira
I think it is related to the #customAlias
part:
import { sayHelloWorldInJapanese } from "#customAlias/helpers";
This helps a lot!
@ilyin371 @kevinoliveira have a fix here:
https://github.com/pzavolinsky/ts-unused-exports/pull/176
If you have the time, it would great to get feedback before we merge and release.
Branch is:
fix/path-aliases-and-sub-folders
fixed in 7.0.0
@mrseanryan sorry for the delay, there are no more false positives.
@mrseanryan has it been resolved? I seem to be having the same issue with the latest version.
In the repro below, there's a single export foo
being reported as unused, despite it clearly being used,
https://github.com/aryzing/practice-ts-unused-exports
Seems to be related to the fact that the file imported is the index file. I've noticed that in the past there have been several issues related to index-related false positives, so may be a regression?
@aryzing thanks for reporting.
This is about the @
part of the import which is not something supported.
import { foo } from "@
foo/index";
Opening as a new issue ...
UPDATE:
Ineed, the problem is the file being imported is index Another very similar file other works OK.
but at this point its simpler for me to manage, as a separate related issue.
Steps to reproduce with
example\with-paths
:utils\src\calculations.ts
into a new sub-folderutils\src\sub\calculations.ts
.math.ts
toimport {calculations} from 'utils/sub/calculations';
ts-unused-exports example\with-paths\tsconfig.json
utils\src\sub\calculations.ts: calculations
is falsely reported as unused.