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 (and friends) index.d.ts for TypeScript #208

Closed
jacogr opened this issue Jun 23, 2018 · 9 comments
Closed

libp2p (and friends) index.d.ts for TypeScript #208

jacogr opened this issue Jun 23, 2018 · 9 comments
Labels
status/deferred Conscious decision to pause or backlog

Comments

@jacogr
Copy link

jacogr commented Jun 23, 2018

  • Version: latest
  • Platform: TypeScript
  • Subsystem: libraries

Type: Question

Severity: Very Low

Description:

I've been starting with TypeScript definitions, https://github.com/polkadot-js/ts/blob/master/types/libp2p/index.d.ts - these are exceptionally early, ugly, hacky, untested with still some way to go.

My question is the following: would be be appropriate to make a PR across the js-libp2p repos to add these as they are actually ready and usable or is there no appetite to have these single-definitions-per-repo included?

(Alternatively could submit them to the community DefinitelyTyped repo, but it is better if they are in the source, i.e. just installing the library allows you to use it with TS projects).

@jacogr jacogr changed the title libp2p (an friends) index.d.ts for TypeScript libp2p (and friends) index.d.ts for TypeScript Jun 23, 2018
@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Aug 25, 2018
@GregTheGreek
Copy link

Is there any update on this?

@jacogr
Copy link
Author

jacogr commented Jan 7, 2019

We have basic typings (very, very, very rough linked above), which does the trick for our stuff internally. The discussions elsewhere was that the libp2p JS side will probably go towards flowtype and at that point may look at auto-generation of the types.d.ts files if it makes sense.

I cannot comment for the libp2p project if this is something that may be entertained at some point or not.

@shroomist
Copy link

I'd like to vote up for TypeScript and down on 'flow'.
Not sure if there was an issue with our project setup, but I've experienced troubles with flow giving false positives on type checks.

@jacobheun
Copy link
Contributor

I'm not opposed to including the TypeScript bindings in each of the libp2p projects, my main concern is ensuring they are kept up to date and automatically verifiable. I have not spent much time with TypeScript as of yet to understand how we could go about making sure these are always accurate.

What tests can we run on CI to ensure these are up to date?
What support is there to autogenerate types for new js code? Can we generate them from JSDocs, etc?

cc: @Mikerah

@Mikerah
Copy link
Contributor

Mikerah commented Apr 19, 2019

There are several options. The one I'm currently using is to use Polkadot-js's type definitions for libp2p. For odd reasons, I am having difficulties with this. The other option is to provide accurate JSDocs for all js-libp2p code and generate typescript definition files from those. I found this package that does this.

@jacobheun
Copy link
Contributor

For odd reasons, I am having difficulties with this

Not sure if it's contributing but the recent version of libp2p includes changes that aren't yet reflected there. This is one of the things I'd like to be able to avoid if we include the definitions in the modules.

We're working on improving JSDocs across libp2p and it's easy enough for us to keep those up to date. Being able to generate from JSDocs could be a reasonable path to getting support added.

@patwhite
Copy link

patwhite commented Aug 3, 2019

Hey guys, did any more types get published, any progress on this issue?

@Mikerah
Copy link
Contributor

Mikerah commented Aug 3, 2019

@patwhite, For our ETH2 client, what we do is set the types ourselves. This does require familiarity with libp2p. We didn't create .d.ts files. If you want an example of how to use js-libp2p in a typescript project, check out lodestar on github.

@vasco-santos
Copy link
Member

We released [email protected] with typedefs generated on release 🎉
Closing this issue, thank you all! There is #659 to track the remaining work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/deferred Conscious decision to pause or backlog
Projects
None yet
Development

No branches or pull requests

8 participants