knip icon indicating copy to clipboard operation
knip copied to clipboard

Support resolving different paths from tsonfig files in monorepo

Open chelentos opened this issue 3 months ago • 2 comments

Suggest an idea for Knip

Hello!

I have a project with this sort of structure:

project
│   tsconfig.ts 
│
└───src
│   │   tsconfig.ts
│   │
│   └───ui
│       │   tsconfig.ts
│       │   ...
│   └───server
│       │   tsconfig.ts
│       │   ...
│   
└───tests

And in every tsconfig file i have some paths set up.

And when I'm using knip it can't resolve it, so i need to specify all of them in paths in knip.json.

I can't use workspaces, cause there is only one package.json.

Maybe there is solution that I can't find?

Would be grateful for any help.

chelentos avatar Nov 10 '25 21:11 chelentos

Unfortunately there is not currently.

Maybe the TypeScript plugin should actually return such path aliases now that we have toAlias. Then you could configure Knip like this:

{
  "typescript": ["**/tsconfig.json"]
}

For now, an idea: use a dynamic config (i.e. knip.config.ts) and something like https://github.com/privatenumber/get-tsconfig to set the Knip paths config.

webpro avatar Nov 11 '25 08:11 webpro

Then you could configure Knip like this:

{ "typescript": ["**/tsconfig.json"] }

Unfortunately this approach not working :(

get-tsconfig seems as overkill for me, but maybe i'll try

Thank you!

chelentos avatar Nov 11 '25 11:11 chelentos