Skip to content

🔄 knip 6 can't handle source mapping if tsconfig outDir has a trailing slash #1635

@astegmaier

Description

@astegmaier

Prerequisites

Reproduction url

https://github.com/astegmaier/playground-knip-6-tsconfig-bug

Reproduction access

  • I've made sure the reproduction is publicly accessible

Good version

5.88.1

Bad version

6.0.3

Description of the regression

When tsconfig.json has "outDir": "lib/" (with a trailing slash):

{
  "compilerOptions": {
    "outDir": "lib/",
    "srcDir": "src/"
  }
}

...and package.json has an export pointing to a lib/ path:

{
  "exports": {
    "./greet": "./lib/greet.js"
  }
  // ...
}

Knip 6 is unable to map lib/greet.js back to src/greet.ts, causing it to report src/greet.ts as an unused file, even though it's correctly exported and used.

Knip 5 handles this case fine.

It's possible to work around this by removing the trailing slash (typscript seems to requard lib/ and lib as equivalent. I thought it would be worth reporting anyways to keep things as seamless as possible for others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionSomething is no longer working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions