-
Notifications
You must be signed in to change notification settings - Fork 43
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
Refactor to use Typescript #77
Conversation
Codecov Report
@@ Coverage Diff @@
## master #77 +/- ##
==========================================
- Coverage 85.68% 80.00% -5.69%
==========================================
Files 11 1 -10
Lines 510 10 -500
==========================================
- Hits 437 8 -429
+ Misses 73 2 -71
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are using typescript it would be useful if you add public/private/protected modifiers so we can navigate easily when extending in lodestar
@vasco-santos Thanks for bringing up the larger issue of standardizing the tooling and strategy for supporting typescript across the js-libp2p/js-ipfs ecosystem. I do think that using full typescript here will be beneficial, over, eg: autogen declarations. Imo it mainly boils down to improved dev tooling and type-checking sanity checks. I think the benefits outweigh the additional machinery and differences with other libp2p repos. The current gossipsub codebase has many rough edges and using typescript here clears up many ambiguities. As part of this process, several bugs were found just from having type-checking. While these bugs were obvious in hindsight, those particular issues would have never passed the base level of scrutiny we get using typescript. I'd love to see this gossipsub implementation be polished and be easily shown to be correct, and I think type-checking plays a role here. The dev tooling aspect is also useful to call out. I've been working on gossipsub v1.1 in a local branch, and having the full IDE type-checking/hinting and autocompletion significantly reduces the mental burden of eg: spelling out logic with app-specific datastructures. We're able to declare datastructures with interfaces (in the case of gossipsubv1.1, these interfaces can be fairly large and wordy) and seamlessly use these to aid development without having to navigate opaque objects by hand. Using vanilla js, I was struggling to have my IDE link JSDocs throughout the project, and having to manually check for typos and correct usage, so the experience was not nearly so pleasant. Remaining thoughts are how to best do this PR w/o negatively impacting the js-libp2p ecosystem and with maximal standardization/collaboration with the js-libp2p ecosystem. I would love to keep using aegir where possible, (using it for linting eventually, if/when supported), and the current structure is an attempt to simply extend the current processes to a typescript codebase. Ideally after ts => js transpilation/pre-processing, "things can be treated the same". Perhaps this may be the only js-libp2p repo using typescript, but I would like to get this right to maximally align with the whole ecosystem so it doesn't have to be treated strangely and can benefit from standardization. |
@wemeetagain thanks for exposing your thoughts. I agree with your thoughts and we should move on the way you are working on! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
FYI, just released |
Pass `maxInboundStreams` and `maxOutboundStreams` options to registrar
## [3.0.1](libp2p/js-libp2p-pubsub@v3.0.0...v3.0.1) (2022-06-17) ### Bug Fixes * limit stream concurrency ([ChainSafe#77](libp2p/js-libp2p-pubsub#77)) ([d4f1779](libp2p/js-libp2p-pubsub@d4f1779))
Refactored to use typescript with minimal changes to process and code.
Imo, using typescript in this project will pay dividends as the gossipsub feature-set grows. It becomes much easier to reason about this codebase which has many moving parts and datatypes when there's that minimal level of type/sanity checking.
That said, I attempted to do this update in a way that's minimally invasive to the standard libp2p workflow.
ts/
, gets transpiled tosrc/
prebuild
andpretest
scripts runstsc
aegir build
src/
not checked into git, likedist/
dist/index.min.js
is 2KB larger, from 468KB to 470KBeslint
(usingstandard
and@typescript-eslint
configs/plugins) instead ofaegir
, as the typescript files themselves are to be lintedGossipSub
=>Gossipsub
throughout (I can remove to future PR if desired)ts/peer.ts
should eventually go tojs-libp2p-pubsub