
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
ast-types-flow
Advanced tools
Flow types for the Javascript AST. Based off of benjamn/ast-types.
First install ast-types-flow
via npm, then you can import any of the types
that are exported.
/* @flow */
import type {Node} from 'ast-types-flow';
function getName(node: Node): string {
switch (node.type) {
case 'Identifier':
return node.name;
case 'ClassDeclaration':
return node.id.name; // Error, id could be null.
case 'FunctionDeclaration':
return node.id.name; // Fine if it's always there.
case 'FunctionExpression':
if (node.id) {
return node.id.name; // Can refine id to make sure it exists.
} else {
return 'Unknown';
}
case 'Literal':
return node.name; // Error, Literals don't have names, don't be silly.
}
return 'Unknown';
}
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:
type Node = {
common: string,
};
type Foo = {
// extends Node
foo: string,
};
type Bar = {
// extends Node
bar: number,
};
Will be transformed into:
type Node = {
type: 'Foo',
_Foo: void,
common: string,
foo: string,
} | {
type: 'Bar',
_Bar: void,
common: string,
bar: number,
};
type Foo = {
type: 'Foo',
_Foo: void,
common: string,
foo: string,
};
type Bar = {
type: 'Bar',
_Foo: void,
common: string,
bar: number,
};
A few things to note:
Node
would more ideally be compiled into Foo | Bar
but then the
disjoint union cannot be properly refined. For now we have to duplicate the
complete definitions._Foo: void
fields
appear in the types.FAQs
Flow types for the Javascript AST
The npm package ast-types-flow receives a total of 11,245,000 weekly downloads. As such, ast-types-flow popularity was classified as popular.
We found that ast-types-flow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.