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

chore: improve types for Hypercore peers #735

Merged
merged 1 commit into from
Aug 16, 2024
Merged

Conversation

EvanHahn
Copy link
Contributor

This is a types-only change.

Before this change, we used any for a Hypercore peer's type.

After this change, we use a new type, HypercorePeer, designed to match Hypercore's Peer class.

Ideally, we would put this in @digidem/types or DefinitelyTyped. For now, I think this is an improvement over the anys we currently use.

I did this because I'm working with peer-related code and found the anys difficult to work with.

*This is a types-only change.*

Before this change, we used `any` for a Hypercore peer's type.

After this change, we use a new type, `HypercorePeer`, designed to match
[Hypercore's `Peer` class][0].

Ideally, we would put this in `@digidem/types` or DefinitelyTyped. For
now, I think this is an improvement over the `any`s we currently use.

I did this because I'm working with peer-related code and found the
`any`s difficult to work with.

[0]: https://github.com/holepunchto/hypercore/blob/de993dc051301f03570df0eb7929c06286745563/lib/replicator.js#L331
@EvanHahn EvanHahn requested a review from gmaclennan July 30, 2024 18:50
@achou11
Copy link
Member

achou11 commented Jul 30, 2024

Just something to consider: seems like that class has changed a bit between the version of hypercore we use and the commit you link to (which is latest commit on their main branch at time of writing).

@EvanHahn
Copy link
Contributor Author

EvanHahn commented Jul 30, 2024 via email

@EvanHahn EvanHahn merged commit a2c0467 into main Aug 16, 2024
7 checks passed
@EvanHahn EvanHahn deleted the hypercorepeer-type branch August 16, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants