{"id":19064,"library":"babel-plugin-flow-to-typescript","title":"babel-plugin-flow-to-typescript","description":"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.","status":"maintenance","version":"0.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/Kiikurage/babel-plugin-flow-to-typescript","tags":["javascript","babel","flow","typescript"],"install":[{"cmd":"npm install babel-plugin-flow-to-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-flow-to-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-flow-to-typescript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as Babel plugin","package":"@babel/core","optional":false}],"imports":[{"note":"Add to Babel config as a plugin string. With @babel/core 7+, use the string name.","wrong":"{\n  plugins: [require('babel-plugin-flow-to-typescript')]\n}","symbol":"plugin","correct":"{\n  plugins: ['babel-plugin-flow-to-typescript']\n}"},{"note":"CommonJS require works; ESM default import may fail if package lacks 'default' export.","wrong":"import plugin from 'babel-plugin-flow-to-typescript';","symbol":"module/require usage","correct":"const plugin = require('babel-plugin-flow-to-typescript');"},{"note":"Standard Babel config file. No special syntax.","wrong":"","symbol":"Babel config (babel.config.js)","correct":"module.exports = {\n  plugins: ['babel-plugin-flow-to-typescript']\n};"}],"quickstart":{"code":"// Install CLI and plugin\n// npm install -g @babel/cli @babel/core\n// npm install babel-plugin-flow-to-typescript\n\n// Run conversion on a Flow file\n// babel --plugins babel-plugin-flow-to-typescript input.js -o output.ts\n\n// Example input (Flow):\n// // @flow\n// function greet(name: ?string): string {\n//   return 'Hello ' + (name || 'world');\n// }\n\n// Example output (TypeScript):\nfunction greet(name: string | null | undefined): string {\n  return 'Hello ' + (name || 'world');\n}","lang":"typescript","description":"Converts a Flow function with maybe type (?string) to TypeScript union with null and undefined."},"warnings":[{"fix":"Update @babel/core to ^7.4.4 or later.","message":"Requires @babel/core ^7.4.4. Older versions may fail.","severity":"breaking","affected_versions":"<7.4.4"},{"fix":"Consider using flow-to-typescript or a manual migration script for modern Flow/TypeScript.","message":"Unmaintained since June 2018. No support for TypeScript 3+ features or newer Flow syntax like $ReadOnlyArray.","severity":"deprecated","affected_versions":"0.6.0"},{"fix":"Manually review imports after conversion; use type-only imports in TypeScript with 'import type'.","message":"Does 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.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Replace $FlowFixMe comments with TypeScript's '// @ts-ignore' or proper types manually.","message":"Transforms $FlowFixMe to any, which may hide real type errors.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev @babel/core@^7.4.4","cause":"@babel/core not installed or wrong version.","error":"Error: Cannot find module '@babel/core'"},{"fix":"Ensure plugin is installed and string name used in plugins array: 'babel-plugin-flow-to-typescript'","cause":"Plugin not found or incorrectly referenced in Babel config.","error":"TypeError: Cannot read property 'convert' of undefined"},{"fix":"Add '@babel/preset-flow' or '@babel/plugin-syntax-flow' before this plugin in plugins array.","cause":"Babel not configured to handle Flow syntax before conversion.","error":"SyntaxError: Unexpected token (1:8) - You may need an appropriate loader to handle this file type."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}