Registry / serialization / babel-plugin-flow-to-typescript

babel-plugin-flow-to-typescript

JSON →
library0.6.0jsnpmunverified

Babel plugin to convert Flow type annotations into TypeScript. Current stable version: 0.6.0. Release cadence is low (last release June 2018). Key differentiator: transforms Flow syntax (exact types, opaque types, $Keys, etc.) directly in Babel pipeline. No type inference, but covers most Flow constructs including maybe types, function types, object types, and utility types like $Diff and $Shape. Requires @babel/core ^7.4.4. Not actively maintained; no support for newer Flow features or TypeScript 3+ syntax.

npm install babel-plugin-flow-to-typescript
INSTALL
IMPORT
SIG · BABEL-PLUGIN-FLOW-
B
babel-plugin-flow-to-typescript
serializationjavascriptv0.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
{ plugins: ['babel-plugin-flow-to-typescript'] }
{ plugins: [require('babel-plugin-flow-to-typescript')] }
Add to Babel config as a plugin string. With @babel/core 7+, use the string name.
module/require usage
const plugin = require('babel-plugin-flow-to-typescript');
import plugin from 'babel-plugin-flow-to-typescript';
CommonJS require works; ESM default import may fail if package lacks 'default' export.
Babel config (babel.config.js)
module.exports = { plugins: ['babel-plugin-flow-to-typescript'] };
Standard Babel config file. No special syntax.

Converts a Flow function with maybe type (?string) to TypeScript union with null and undefined.

// Install CLI and plugin // npm install -g @babel/cli @babel/core // npm install babel-plugin-flow-to-typescript // Run conversion on a Flow file // babel --plugins babel-plugin-flow-to-typescript input.js -o output.ts // Example input (Flow): // // @flow // function greet(name: ?string): string { // return 'Hello ' + (name || 'world'); // } // Example output (TypeScript): function greet(name: string | null | undefined): string { return 'Hello ' + (name || 'world'); }
Debug
Known issues
breakingRequires @babel/core ^7.4.4. Older versions may fail.
fix
Update @babel/core to ^7.4.4 or later.
affects: <7.4.4
deprecatedUnmaintained since June 2018. No support for TypeScript 3+ features or newer Flow syntax like $ReadOnlyArray.
fix
Consider using flow-to-typescript or a manual migration script for modern Flow/TypeScript.
affects: 0.6.0
gotchaDoes not handle Flow import type syntax fully; import type A from 'module' becomes import A from 'module' (removes type-only), which may cause runtime errors if module has no default export.
fix
Manually review imports after conversion; use type-only imports in TypeScript with 'import type'.
affects: >=0.3.0
gotchaTransforms $FlowFixMe to any, which may hide real type errors.
fix
Replace $FlowFixMe comments with TypeScript's '// @ts-ignore' or proper types manually.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Cannot find module '@babel/core'
@babel/core not installed or wrong version.
fix
npm install --save-dev @babel/core@^7.4.4
TypeError: Cannot read property 'convert' of undefined
Plugin not found or incorrectly referenced in Babel config.
fix
Ensure plugin is installed and string name used in plugins array: 'babel-plugin-flow-to-typescript'
SyntaxError: Unexpected token (1:8) - You may need an appropriate loader to handle this file type.
Babel not configured to handle Flow syntax before conversion.
fix
Add '@babel/preset-flow' or '@babel/plugin-syntax-flow' before this plugin in plugins array.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
@babel/corerequiredRequired as Babel plugin
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
babel-plugin-flow-to-typescript — npm install babel-plugin-flow-to-typescript · libregistry