Prerequisites
Reproduction url
https://github.com/agneym/knip-v6-tsconfig-paths-repro
Reproduction access
Good version
5.64.0
Bad version
6.0.0 and still present in latest 6.16.1
Description of the regression
In Knip v5, --tsConfig tsconfig.app.json used that tsconfig's compilerOptions.paths for module resolution. In Knip v6, the selected tsconfig is loaded, but its compilerOptions.paths do not appear to be used for resolving imports in discovery mode.
Repro commands:
git clone https://github.com/agneym/knip-v6-tsconfig-paths-repro.git
cd knip-v6-tsconfig-paths-repro
pnpm install
pnpm knip
The repo has this shape:
tsconfig.json has no compilerOptions.paths.
tsconfig.app.json extends tsconfig.json and defines @app/* -> ./src/*.
knip.ts has no paths.
src/main.ts imports src/used.ts via @app/used.
src/unused.ts is truly unused.
Expected with:
knip --include files --tsConfig tsconfig.app.json --no-progress --reporter compact
Only the truly unused file should be reported:
Actual with Knip v6.16.1:
src/unused.ts: src/unused.ts
src/used.ts: src/used.ts
If I duplicate the alias in Knip config via paths, then v6 reports only src/unused.ts, which suggests the import itself is fine and the issue is specifically that compilerOptions.paths from the selected --tsConfig file is not feeding module resolution.
Confirmed regression:
pnpm dlx knip@5.64.0 --include files --tsConfig tsconfig.app.json --no-progress --reporter compact
reports only:
while:
pnpm dlx knip@6.0.0 --include files --tsConfig tsconfig.app.json --no-progress --reporter compact
reports both files.
Note: --use-tsconfig-files reporting no unused files is not the concern here; the FAQ explains that tsconfig files become program files and are not reported as unused. This regression is about normal discovery mode with --tsConfig not using the selected tsconfig's compilerOptions.paths for module resolution.
Prerequisites
Reproduction url
https://github.com/agneym/knip-v6-tsconfig-paths-repro
Reproduction access
Good version
5.64.0Bad version
6.0.0and still present in latest6.16.1Description of the regression
In Knip v5,
--tsConfig tsconfig.app.jsonused that tsconfig'scompilerOptions.pathsfor module resolution. In Knip v6, the selected tsconfig is loaded, but itscompilerOptions.pathsdo not appear to be used for resolving imports in discovery mode.Repro commands:
git clone https://github.com/agneym/knip-v6-tsconfig-paths-repro.git cd knip-v6-tsconfig-paths-repro pnpm install pnpm knipThe repo has this shape:
tsconfig.jsonhas nocompilerOptions.paths.tsconfig.app.jsonextendstsconfig.jsonand defines@app/* -> ./src/*.knip.tshas nopaths.src/main.tsimportssrc/used.tsvia@app/used.src/unused.tsis truly unused.Expected with:
Only the truly unused file should be reported:
Actual with Knip v6.16.1:
If I duplicate the alias in Knip config via
paths, then v6 reports onlysrc/unused.ts, which suggests the import itself is fine and the issue is specifically thatcompilerOptions.pathsfrom the selected--tsConfigfile is not feeding module resolution.Confirmed regression:
reports only:
while:
reports both files.
Note:
--use-tsconfig-filesreporting no unused files is not the concern here; the FAQ explains that tsconfig files become program files and are not reported as unused. This regression is about normal discovery mode with--tsConfignot using the selected tsconfig'scompilerOptions.pathsfor module resolution.