A blog post by the Flow team describes a "re-architecture" of Flow called "types-first". As far as I can tell, the only description is in this quote from the blog post:
"...it exploits full type annotations at file boundaries to perform better (more parallelizable and less redundant) separate compilation."
Is there more detail about this anywhere? Specifically, I'm wondering what these full annotations are: what are the new restrictions on source code and declaration files?
For example, is this allowed?
import { func } from "./other-module";
export const myNumber = func(num1, num2);
It's problematic in TypeScript, since the type of myNumber
is impossible to resolve without knowing the type of func
. Will the "types-first" re-architecture of Flow require users to write:
import { func } from "./other-module";
export const myNumber: number = func(num1, num2);
This is just one specific question I have. What I'm looking for is a little bit more information and a link to a document explaining all the known implications of the re-architecture.
TL;DR: The types-first architecture unlocks Flow’s potential at scale by leveraging fully typed module boundaries. We plan to migrate to the new architecture over the next months. Flow is designed to type check extremely large projects.
The workflow consists of a series of transformations on the input information, where information and operations are independent of each other. In this article we have discussed three Data flow architectures namely Batch Sequential, Pipe & filter, and Process Control architecture.
The workflow consists of a series of transformations on the input information, where information and transformation methods are independent of each other. In a data flow architecture, information is pulled into the system which then flows through several modules and goes through transformation until destination (output or a data store) is achieved.
This architecture led to a variety of performance problems, including peak memory blowups, long garbage collection pauses, amplification of non-linear time complexity, and low use of parallelism. On the other hand, in types-first, w e compute the types of the upstream files directly, since module boundaries must have full type annotations.
It sounds really flashy and maybe it is under the hood. But in reality it's quite simple. In your code snippet you're absolutely correct, it pretty much means just that.
You must have an explicitly defined type before you export
Though not necessarily right before you export. The following works too.
const TestComponent = (): React.Node => {};
export default TestComponent;
It adds a little more overhead, but the benefits are:
They've also released a new blog post that goes into this further since types first have now been released officially. https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb
UPDATE The types-first architecture is now documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With