Skip to content

Published .d.ts references bundled @libp2p/interface, causing duplicate PeerInfo types #352

@Rinse12

Description

@Rinse12
  • Environment

  • Steps to Reproduce

    1. Install Helia ([email protected]) alongside [email protected].
    2. Import PeerInfo from the hoisted @libp2p/interface (e.g. in src/helia/util.ts).
    3. Call helia.libp2p.contentRouting.findProviders, which yields PeerInfo from kubo-rpc-client/dist/....
    4. Run tsc.
  • Actual Behavior
    TypeScript raises:

    error TS2345: Argument of type 'import(".../node_modules/kubo-rpc-client/node_modules/@libp2p/interface/dist/src/peer-info").PeerInfo'
    is not assignable to parameter of type 'import(".../node_modules/@libp2p/interface/dist/src/peer-info").PeerInfo'.
      Types of property 'multiaddrs' are incompatible.
    

    The published declaration points at kubo-rpc-client/node_modules/@libp2p/interface, so TypeScript treats it as a different module identity even though the package versions match. Running npm dedupe or otherwise flattening dependencies doesn’t change the emitted import path inside the .d.ts.

  • Expected Behavior
    The generated declarations should import PeerInfo (and Multiaddr) from the public package path (@libp2p/interface / @multiformats/multiaddr) so consumers get a single type identity.

  • Suggested Fixes / Notes

    • Move @libp2p/interface (and @multiformats/multiaddr) to peer dependencies so only one copy is installed.
    • Alternatively, ensure the build emits type imports from the top-level package path instead of the nested node_modules location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions