-
-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to get Knip to respect tsconfig compilerOptions.paths
#546
Comments
Apologies for the time lost, I need to document this. You're not the first to face this strictness of Knip, and it's indeed not clear what's off. My guess is that Overall, I'm inclined to think path aliases shouldn't be used to cross workspace boundaries. Happy to hear counter arguments. |
Thank you for the quick feedback, and no problem. You are indeed correct that the workspace dependency is configured in
TypeScript seems pleased with these changes, but I'm afraid that the output from Knip remains the same. It seems clear to me now that we would need a minimal reproduction in order to investigate further. I think it is unlikely I'll find the time to prepare that anytime soon, but if I'm wrong then I'll come back with an update. No problem to close this issue so it doesn't hang around open in your queue. |
Just to be sure:
We can leave this open until I've documented it somewhere. |
Yes, I reinstalled dependencies after adding the workspace dependency configuration to
Oh, I'm glad you asked. I just tried this, and the result is not what I expected. When I remove the It seems there is something about enums, or about the specific enum in my project, that causes the enum members to be reported as unused despite the workspace dependency configuration that otherwise seems to function as expected. |
There's two notes I should make here:
Based on the above, I don't think enums are the issues here. |
Ah I see, makes sense. I think we have been able to confirm that modifying
Well, following your advice, I have added the workspace dependency to If I ever manage to put together a minimal reproduction, then I'll be sure to let you know. |
Closing this. Feel free to open a new issue with a minimal reproduction. Related/potential fix: #611 |
After extensive testing and reading through Knip's documentation, I have been unable to find any more than a workaround for the following issue. In checking to see if this issue has been reported before, the closest I could find was #388, but that seems to be a bit different. Apologies if there was another report that I missed.
I haven't managed to create a minimal reproduction, but please let me know if that would be necessary here. Unfortunately I'm unable to link to the source files as this is a company project.
My project consists of three workspaces:
root
, which contains the Knip config and the other two workspaces.workspace-1
, which contains several exports used by bothworkspace-1
andworkspace-2
.workspace-2
, which uses some exports fromworkspace-1
, but which shares none of its own exports with other workspaces.Here is a simplified representation of the folder structure:
workspace-2
uses exports fromworkspace-1
by way of the following config inworkspace-2/tsconfig.json
:workspace-1/src/shared/bar.ts
contains an enum like the following:The exported
Plants
enum is imported in both workspaces:workspace-1/src/foo.tsx
imports thePlants
enum and uses it as a type but does not access any of the enum members.workspace-2/src/baz.ts
imports thePlants
enum and accesses all of the enum members.When I run Knip, the
Plants
enum members get reported as unused:Is there any way to configure Knip to respect the
compilerOptions.paths
setting inworkspace-2/tsconfig.json
so that the enum members aren't reported as unused?I have scoured the Knip docs and tried every seemingly related suggestion I could find, including the suggestion to not explicitly set
compilerOptions.baseUrl
, to no avail. The only suggestion that has actually silenced the report is prepending the exported enum with/** @public */
, but that feels like more of a workaround than a solution.Apologies for the long post. If I can provide clarification, please just let me know. Thank you!
The text was updated successfully, but these errors were encountered: