Code Monkey home page Code Monkey logo

Comments (10)

litera avatar litera commented on September 24, 2024 1

I have a similar situation. I have a .js file and I'm using an export from it in a .ts file. When I use the imported function I get typescript errors related to types. For that reason I created a .d.ts that only defines types for the exports in the .js file so I don't have any typescript errors any more.
But... Now knip comlpains about the .js file not being used. IMO this is a bug, because knip should assume, that .d.ts files don't contain any implementation, but rather only definitions.

from knip.

alexeyr-ci avatar alexeyr-ci commented on September 24, 2024 1

Works for my version of the issue.

from knip.

EvgenyOrekhov avatar EvgenyOrekhov commented on September 24, 2024

Knip version: 4.5.0
Node.js version: 20.10.0

from knip.

litera avatar litera commented on September 24, 2024

Seems a PR is in the works for this:
#503

from knip.

alexeyr-ci avatar alexeyr-ci commented on September 24, 2024

Yet another effect probably from the same reason:

For that reason I created a .d.ts that only defines types for the exports in the .js file so I don't have any typescript errors any more.

In my case exports used only in that .js file are reported as unused (though I haven't been able to reproduce this in a minimized project). Knip version is 5.0.2.

from knip.

webpro avatar webpro commented on September 24, 2024

🚀 This issue has been resolved in v5.1.3-canary.0. See Release 5.1.3-canary.0 for release notes.

from knip.

webpro avatar webpro commented on September 24, 2024

Would be great if you could try out this version before I'll release v5.1.3 (I'm not in a hurry btw)

from knip.

EvgenyOrekhov avatar EvgenyOrekhov commented on September 24, 2024

@webpro 5.1.3-canary.0 didn't fix it for me :(

from knip.

webpro avatar webpro commented on September 24, 2024

It does for me, although I did add an (empty) tsconfig.json to your example.

from knip.

EvgenyOrekhov avatar EvgenyOrekhov commented on September 24, 2024

In my actual project I have this in my tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "src"
  },
  "include": ["./"]
}

from knip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.