Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Add flow type signatures. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add flow type signatures. #62

wants to merge 1 commit into from

Conversation

Gozala
Copy link

@Gozala Gozala commented Jan 10, 2018

As dive into ipfs / libp2p code base I struggle to guess what are all the things passed around. Types as in flow (or typescript for that matter) simplify learning of how things are connected significantly. There for I decided to contribute type signatures to the code base as I digg through it.

What's up with all these .js.flow files ?

Unfortunately flow project has yet to come up with coherent story of how to provide type annotations for third party libraries. In my experience adding .js.flow files works best out of all options, that is because flow type checker when gives a precedent to /path/to/file.js.flow over /path/to/file.js which essentially provides a way to provide type annotations for non-flow typed package such that just using it as dependency will satisfy both type checker and run-time.

It's far from ideal given that .js and .js.flow files can get out of sync but then again unless you're open to adopt flow this is the best option IMO.

Depends on libp2p/js-peer-id#75

@dryajov
Copy link
Member

dryajov commented Jan 10, 2018

Is there anyway of distributing the typings as a separate package (similar to typescript @type/<package>), so that we don't clutter this package with language specific types?

@Gozala
Copy link
Author

Gozala commented Jan 10, 2018

Is there anyway of distributing the typings as a separate package (similar to typescript @type/), so that we don't clutter this package with language specific types?

@dryajov there is flow-typed but sadly it's not nearly as good as in typescript and most flow users don't seem to use it for that reason. It is also that there is advantage of having type definitions with implementations as that gives some initiative to library contributors to keep them in sync otherwise they just don't match up (at least that is a big issue with flow-typed) type defs.

@dryajov I think this conversation on how to add types probably should be discussed under https://github.com/ipfs/community/issues/278

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants