question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it currently possible to have dependencies between library definitions?

See original GitHub issue

I am pretty confused about this. Issues like #16 and #1494 seem to suggest that this isn’t currently doable, but definitions like react-redux seem to be doing it. Is redux a special case or something that allows for this, or is this actually possible for any library?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:43 (41 by maintainers)

github_iconTop GitHub Comments

14reactions
EdwardDrapkincommented, Dec 22, 2018

I’m here to second what @saadq said. Our next React web project at work is going to be TypeScript so we can evaluate if the React-specific stuff in Flow (e.g. ElementConfig, etc.) outweigh the other benefits that TS brings over Flow. This is the issue that kills Flow adoption every time I try to have a conversation with anyone.

I spent several dozen hours spread across many lunch breaks, weekends, and evenings working on this repository, trying to find a way to fix this issue and open a PR that would at least be a POC that could move the conversation forward, but the code quality of the flow-typed code itself is so (no offense, my apologies) abhorrent that my recommendation (were this a project I was getting paid to work on) would be to greenfield a version 2.0 and manually import code that is still useful going forward. That is an enormous task, however, and it seems like there isn’t bandwidth available here in the community to actually get it done. We have over 100 complete, accurate type definition files for various node modules that we can’t contribute back upstream because transitive dependencies don’t work in flow-typed and it’s prohibitively difficult to fix. And that’s with two people in the entire department who have the expertise and willingness to actually write libdefs. I shudder to think how many thousands of libdefs a company with actual size would have to be sitting on.

There’s nothing that a TS typedef file can define that a Flow libdef cannot also describe AFAIK. If the community wants Flow to succeed, the only way I can see out of this mire is to abandon flow-typed altogether and invest every community effort into making the flow server able to read TS libdef files (or a userspace cross compiler to translate one into the other). Otherwise, the DefinitelyTyped community is way too far ahead of where Flow is, the tooling support in IDEs is much further ahead, and like others have said, Facebook’s cold shoulder to the Flow community is as good as a middle finger.

FWIW, I think Flow is a superior product to TS for a multitude of technical reasons, but every other thing about the choice goes to TS right now, and Facebook has not shown that they are willing to fight Microsoft in this cage, so how can anyone in good faith recommend Flow any more? If the Flow community could just absorb the work that the TS community has done - both in typing JS packages and consuming TS code’s type information too - that would solve a lot of these issues.

12reactions
villesaucommented, Mar 7, 2018

There are two different ways of importing in libdefs:

import type { MyType } from 'some-module';
declare module 'other-module' {
  declare export function takesMyType(val: MyType): number;
}

and the second is this:

declare module 'other-module' {
  import type { MyType } from 'some-module';
  declare export function takesMyType(val: MyType): number;
}

How are these different from each others? The first one does not work and returns any type, the second one works. Also, AFAIK second approach only supports importing types, so e.g classes etc are tricky. I haven’t tried if you can import class on the top of the file and use it’s type with typeof, it might also just turn out to be any.

Unfortunately flow-typed does not currently support the second approach as it can’t depend on other libdefs during the tests. Other problem is nasty dependencies between library definitions which might become very hard to maintain.

Ideally flow-typed would support dependencies between libdefs, and in optimal situation flow-typed install module@1.2.3 would also install possible dependencies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between a library and a dependency?
Libraries and dependencies are like persons and relatives: One is just an entity (something), the other is a relational entity.
Read more >
How to Ensure That Your Dependencies Are Up to Date
Commonly referred to as a "dependency of a dependency", a transitive dependency is a library called by one of your direct dependencies.
Read more >
Sharing dependency versions between projects
Catalogs can separate the group and name of a dependency from its actual version and use version references instead, making it possible to...
Read more >
Android library development - Dependencies - Jeroen Mols
How many transitive dependencies should your SDK have? This post will cover how transitive dependencies of an Android library affect Apps ...
Read more >
Dependencies analysis | IntelliJ IDEA Documentation - JetBrains
If you have a large Java project with several modules that uses multiple libraries, any operation that requires an essential structural change can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found