babel-flow-types

raw JSON →
1.2.3 verified Sat Apr 25 auth: no javascript maintenance

Provides Flow type definitions for Babel's public API, including types for AST nodes, parsers, transformers, and code generation. Current stable version is 1.2.3. This package is specifically for Flow users who need type coverage when working with Babel's ecosystem, offering types that mirror Babel's internal structures. It is updated infrequently to match Babel's releases. Compared to TypeScript-oriented alternatives like @babel/types, this package is the primary source for Flow consumers relying on Babel.

error Cannot resolve 'babel-flow-types'.
cause Package not installed or not in node_modules.
fix
Run 'npm install babel-flow-types' to add it to dependencies.
error TypeError: Cannot read properties of undefined (reading 'body')
cause Trying to use BabelNodeFile as a runtime value instead of a type.
fix
Remove 'type' keyword from import to import the actual value, but note that this package only exports types.
error Flow: Cannot resolve module 'babel-flow-types'.
cause Flow cannot locate the package because it's a flow-typed library or not in flow-typed.
fix
Add '// flow-typed' comment or install flow-typed definitions for babel-flow-types.
deprecated This package is in maintenance mode and may not be updated for newer Babel versions.
fix Consider migrating to TypeScript with @babel/types or continue using Flow with caution.
gotcha Flow type definitions may not cover all Babel APIs; some types are missing or incomplete.
fix Check the package's source to see defined types; supplement with custom type definitions as needed.
gotcha Importing types incorrectly (e.g., with default import) will cause Flow errors.
fix Use named type imports as shown in the examples.
npm install babel-flow-types
yarn add babel-flow-types
pnpm add babel-flow-types

Shows how to import and use a BabelFlow type in a Flow-typed file.

// @flow
import type { BabelNodeFile } from 'babel-flow-types';

function processFile(node: BabelNodeFile) {
  console.log(node.program.body);
}

processFile({ type: 'File', program: { type: 'Program', body: [], directives: [], sourceType: 'module', interpreter: null } });