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

libp2p.components not included in typescript types. #2452

Open
MichaelJCole opened this issue Mar 27, 2024 · 1 comment
Open

libp2p.components not included in typescript types. #2452

MichaelJCole opened this issue Mar 27, 2024 · 1 comment
Labels
need/triage Needs initial labeling and prioritization

Comments

@MichaelJCole
Copy link
Contributor

MichaelJCole commented Mar 27, 2024

  • Version:
    "libp2p": "^1.2.3",

  • Platform:
    Linux

  • Subsystem:

Severity:

High - The main functionality of the application does not work, API breakage, repo format breakage, etc.

Description:

Separating types into an interface creates a lot of extra work.

The point of typescript is to have the code, types, and documentation in the same place. The types are the documentation.

So the interface doesn't include components, but the implementation makes components public.

It's very difficult to contribute to this project because the code is spread all over the place.

It's not clear to me how to fix it in the interface package.

Components type can be exported from libp2p allowing for workarounds in the apps that use libp2p.

Steps to reproduce the error:

Try to get the results of what AutoNAT is doing.

@MichaelJCole MichaelJCole added the need/triage Needs initial labeling and prioritization label Mar 27, 2024
@MichaelJCole
Copy link
Contributor Author

To access the address manager, here is a workaround:

import { DefaultAddressManager } from 'libp2p/dist/src/address-manager'

// @ts-ignore broken libp2p types
const am = libp2p.components.addressManager as DefaultAddressManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

1 participant