Closed taro-28 closed 4 weeks ago
Thanks for catching this, nice.
I did just quite the refactoring last week and now there's toConfig
indeed to mark such references as configuration files.
There's just one catch: path
value can be a reference to a folder as well, and Knip doesn't resolve that to the tsconfig.json
file inside that folder. So I think we can just filter out everything that doesn't end with .json
. I had the same issue when parsing the -p/--project
argument on the command-line here: https://github.com/webpro-nl/knip/blob/c9afd52e4e778b57caa2b811798851c794a7df92/packages/knip/src/plugins/typescript/index.ts#L45
We could actually resolve a specifier like ./some/workspace
to that workspace's tsconfig.json
file, but my assumption is that the file is already handled in that workspace.
A PR would be greatly appreciated!
Thank you for your reply.
So I think we can just filter out everything that doesn't end with .json. I had the same issue when parsing the -p/--project argument on the command-line here
I see, I hadn't noticed this, so it was helpful to have your comment in advance.
my assumption is that the file is already handled in that workspace.
I agree with you.
I will now try to make a PR!
Suggest an idea for this project
Hello!
I encountered a issue where the dependencies used in tsconfig specified in the references of tsconfig are detected as unused dependencies.
Reproduction
https://stackblitz.com/edit/knip-typescript-references?file=tsconfig.json
Suggestion
I thought I could just add the
references
path to the config file path in the TypeScript plugin'sresolveConfig
as well asextends
.https://github.com/webpro-nl/knip/blob/c9afd52e4e778b57caa2b811798851c794a7df92/packages/knip/src/plugins/typescript/index.ts#L24-L26
I will create a PR if the above suggested methods are acceptable!