Comments (10)
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.
Works for my version of the issue.
from knip.
Knip version: 4.5.0
Node.js version: 20.10.0
from knip.
Seems a PR is in the works for this:
#503
from knip.
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.
🚀 This issue has been resolved in v5.1.3-canary.0. See Release 5.1.3-canary.0 for release notes.
from knip.
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.
@webpro 5.1.3-canary.0 didn't fix it for me :(
from knip.
It does for me, although I did add an (empty) tsconfig.json
to your example.
from knip.
In my actual project I have this in my tsconfig.json
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["./"]
}
from knip.
Related Issues (20)
- Imports with foreign file extensions fail with "Unable to find" file error HOT 13
- --cache-location is an unknown option HOT 2
- Programatically Run HOT 1
- Re-exports with usage of barrel files isn't indexed correctly HOT 6
- Support for external plugins HOT 1
- Commitlint plugin: specifier.startsWith is not a function HOT 1
- commitlint plugin update breaks when `parserPreset` isn't a `string`
- SvelteKit Demo App $app/* unresolved HOT 2
- 5.14.0 breaks knip in git submodules
- Documentation Site Version Selector leads to 404 HOT 2
- Support local custom plugin HOT 2
- Support import.meta.resolve (in Pino v7+ transports) HOT 3
- Unused functions are not being detected HOT 5
- Default import name being used to determine if export is used HOT 7
- Re-exported enum members incorrectly reported as unused HOT 7
- False positive when using a dynamic default importing HOT 2
- Module '"knip"' has no exported member 'KnipConfig'. Did you mean to use 'import KnipConfig from "knip"' instead? HOT 3
- "ignore" file working even though it shouldn't based on the docs HOT 4
- [Svelte@5] Knip fails to resolve `*.svelte.(j|t)s` files HOT 4
- Run the script only against the staged files. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knip.