Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Imports in declare module are not detected (TypeScript) #953

Open
6 tasks done
fregante opened this issue Feb 21, 2025 · 1 comment
Open
6 tasks done

🐛 Imports in declare module are not detected (TypeScript) #953

fregante opened this issue Feb 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@fregante
Copy link

fregante commented Feb 21, 2025

No repro

Prerequisites

Reproduction url

Stub issue, I can create a repro if required

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

npm install react-select react-select-virtualized

I have this in my globals.d.ts file and knip is missing the usage of "react-select":

// Package has no types: https://github.com/guiyep/react-select-virtualized/issues/293
declare module "react-select-virtualized" {
  export { default } from "react-select";
  // https://deluxe-blancmange-4a5494.netlify.app/#/?id=usage-with-creatable
  export { Creatable } from "react-select/creatable";
}

I can confirm that:

@fregante fregante added the bug Something isn't working label Feb 21, 2025
@fregante
Copy link
Author

fregante commented Feb 21, 2025

Here's a smaller repro that doesn't make use of @types packages, to avoid confusion:

Download

repro.zip

Code

// global.d.ts
declare module "my-lil-error-checker" {
    export { isErrorLike } from "serialize-error";
}

Output:

Unused dependencies (1)
serialize-error  package.json:4:6
Unlisted dependencies (1)
my-lil-error-checker  index.ts
  • Unlisted dependencies is expected, it doesn't exist.
  • Unused dependencies is the bug/feature request

Like in the original post, adding import "serialize-error" at the top of global.d.ts recognizes the usage of the dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant