Packages re-exported under different name through typescript module declaration
Reproduction url
https://codesandbox.io/p/devbox/gq2qss?file=%2Fremotes.d.ts
Description of the issue
We're using module federation and import from remote containers at run time. To provide type safety, we use types from the packages that provide remote containers, and re-export those types through typescript module declaration, so that the types match the names of federated containers as defined in federation configuration:
// This module name is used in module federation configuration
declare module "@my/remote-container" {
// This is a type-only re-export from a package that
// provides a remote container from module federation
export * from "actual-remote-container-package";
}
In another file:
// This import works in real setup only at runtime,
// because it refers to a remote container from module federation
import {SomeThing} from '@my/remote-container';
SomeThing.foo();
With this setup knip reports both the package used to export types from under declare module as "Unused" and the import from the declared module as "Unlisted":
> knip
Unused devDependencies (1)
actual-remote-container-package package.json
Unlisted dependencies (1)
@my/remote-container index.ts
Thanks @allista, this is indeed an yet unsupported feature.
FYI, at this point I'm not implementing new features so for now you could use the ignore* options (which can be regexes if that's useful).
Somewhat related feature request:
- https://github.com/webpro-nl/knip/issues/953
Closing this issue as part of a general cleanup to keep this project sustainable and optimize my time working on it. If you think this is inappropriate or if there is no workaround and you feel stuck, feel free to open a new issue. Thanks for your understanding.