Sorry for not providing a reproduction, I tried one here that best resembles my project setup with minimum complexity.
Workspace
b
is using only a subset of workspacea
. In the current state,packages/a/src/utils/unused.ts
should be flagged as an unused file/all of its exports should be flagged as unused, and inpackages/a/src/utils/used.ts
, only theaFoo
variable is being used, so theaBar
export/variable should be flagged as unused.The repo uses TS project references and workspaces (here npm, although mine is Yarn, but I don't believe it makes a huge difference), so the dependency between workspaces is seen both through the project references' setup (
packages/b/tsconfig.json
contains a project reference topackages/a/tsconfig.json
) and through the regular dependencies (packages/b/package.json
has a"@internal/a": "*"
dev dependency). You can make sure that everything works properly by runningnpm run b
(I've made this script readily available in the root), it should simply displayaFoo
.Both workspaces define a
"exports": { "./*": "./src/*.ts" }
subpath export, which basically makes every file available from the outside. So technically, I guess this warrants anentry: ['./src/**']
config in Knip as every file could be accessed, so that's what I've done here. But despite that, we still want to know whether some of those files (and the exported variables inside) are unused, hence addingincludeEntryExports: true
to Knip's config.Despite all this, if you run
npm run knip
(which I've setup to just target thepackages/a
workspace), the current result is the following, which isn't what I expected:Unused exports (3) unusedVar unknown packages/a/src/utils/unused.ts:1:14 aFoo unknown packages/a/src/utils/used.ts:1:14 aBar unknown packages/a/src/utils/used.ts:2:14
Do you reckon my usage makes sense for Knip to analyze? Am I misconfiguring or misunderstanding something? Can you confirm the current configuration is correct (or not) and would work if this current issue were to be tackled?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too