Skip to content

Ensure that @types/* used in emitted declarations are in dependencies #248

Description

@alecmev

I'm not sure if this is in scope of Knip, but it feels like it could be. In a nutshell, if I have a module like this:

// bar/src/index.ts
import type { Foo } from "foo";
export const bar = (): Foo => ...

And foo comes with a corresponding @types/foo, then I need to make sure that it's actually in dependencies. Otherwise bar/dist/index.d.ts will be broken in any consumer of bar that doesn't have @types/foo in its dependency tree.

The complication I'm seeing is determining whether a @types/* actually ends up being used in dist. And putting all @types/* in dependencies doesn't make sense, obviously. Does TypeScript have an API of any sort for checking this?

More context in this Stack Overflow question.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions