Closed me4502 closed 1 month ago
The repro is inaccessible to me (404)
ah sorry, i seem to have a lot of issues with that codesandbox site disconnecting for me. i'll create a GitHub reproduction case tomorrow.
I've just switched it out with a GitHub repo, and after some investigation i've also slightly altered the issue to better reflect what I believe is the underlying cause.
Thanks for the reproduction.
The problem here is that Knip uses ts.readConfigFile
which returns the final TS configuration (per workspace). There's no way to stop when descending into other local workspaces through extends
(while we do want to recursively load TS config files local to the workspace).
A solution I can think is a custom TS config reader for the TypeScript plugin that does stop when traversing into other workspaces.
Working on some refactorings and things are coming together nicely, including recursively handling config files in their own workspace. Which is what should handle this case a lot better. It seems to handle the example repo well. This will be included in the next version. You could try an early build if you like:
npm i -D https://pkg.pr.new/knip@c03f963
Thanks, I can confirm that fixes the problem :)
Going to close with the release of v5.34.0
Prerequisites
Reproduction url
https://github.com/me4502/knip-reproduction
Description of the issue
When you include entries exported via package.jsonexports
in a tsconfig file'stypes
field, Knip looks for the full path rather than the package that it's included in for theunlisted
check. For example in the reproduction codesandbox, it looks for@monorepo/helper-types/base
and@monorepo/helper-types/other
, rather than just@monorepo/helper-types
which is already included in the dependencies field.When you extend a shareable tsconfig file coming from a package, Knip will expect any packages mentioned in the "types" field of the shareable config to also be present in all configurations that extend it. This is unnecessary as those are dependencies of the package that serves the shareable tsconfig file.