Olle Härstedt
Olle Härstedt

Reputation: 4020

Does Flow work with any JavaScript framework?

Not looking for any recommendations, just an objective assessment if any JavaScript framework can be type-checked with Flow in the current state.

With Flow decreasing in popularity compared to TypeScript, framework declaration files tend to be written in TypeScript, and conversion is not trivial nor automatic. Is there still a framework that works well with Flow type inference, or for which you can write your own framework declarations on the fly? Or is Flow mostly used for framework-agnostic business logic today?

Upvotes: 0

Views: 81

Answers (2)

Brianzchen
Brianzchen

Reputation: 1335

So the main one is react, given that its type defs are built directly into the flow project. The other which I haven't looked into personally is Vue, given that it's written in flowtype. But I cannot confirm how to get their type defs as I haven't used it personally.

But even if a library doesn't ship with type defs, it doesn't mean it doesn't support flow. One clear example is styled-components, it's built in flow with first class flow support but do not ship out of the box. Instead their defs are shipped via flow-typed. I'm not sure what their reasoning is, but most likely it's to remove coupling of flow version with styled-component version, and consumers can upgrade each independently.

Overall if you can't find a lib def readily, either not many people use it with flow or the consumers don't bother and just use the types as any. Since there are many projects in the world that don't use any static type checker, having partial static analysis may be good enough.

Upvotes: 1

Olle Härstedt
Olle Härstedt

Reputation: 4020

Answering my own question, I think looking into the flow-typed repo and look for a particular lib or framework will answer this. No recent update = no support, unless you have time and interest to make a PR yourself.

https://github.com/flow-typed/flow-typed

Upvotes: 0

Related Questions