ast-types-flow
Flow types for the Javascript AST. Based off of benjamn/ast-types.
Usage
First install ast-types-flow
via npm, then you can import any of the types that are exported.
How it works
A notion of "extends" is added to the Flow syntax via comments. A transform is included that will compile the source code into useful disjoint union types based on how the different types extend each other. For example:
Will be transformed into:
A few things to note:
The type
Node
would more ideally be compiled intoFoo | Bar
but then the disjoint union cannot be properly refined. For now we have to duplicate the complete definitions.Each entry in a disjoint union has to be structurally unique or Flow will have an error on the definition. That is why the private
_Foo: void
fields appear in the types.
Last updated