{"id":19142,"library":"babel-plugin-reflow","title":"babel-plugin-reflow","description":"Babel plugin to transpile Flow type annotations to TypeScript, with a CLI wrapper for batch conversion. Current stable version 0.5.7 (latest). Development appears slow but active with periodic releases. Key differentiators: focuses on pretty output via Prettier, handles comments well, proven on real projects (27k and 41k LOC). Compared to alternatives like flow-to-ts or babel-plugin-flow-to-typescript, Reflow offers a CLI and better output formatting. Supports base types, generics, utility types, nullable types, optional chaining, nullish coalescing, and class decorator replacement. Limitation: empty Flow object types become `object` not `{}` since v0.5.","status":"active","version":"0.5.7","language":"javascript","source_language":"en","source_url":"https://github.com/grubersjoe/reflow","tags":["javascript","babel-plugin","flow","typescript","babel-plugin-flow","babel-plugin-typescript","babel-plugin-flow-to-typescript","babel-plugin-flow-to-ts"],"install":[{"cmd":"npm install babel-plugin-reflow","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-reflow","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-reflow","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Babel plugin runs on Babel core","package":"@babel/core","optional":false},{"reason":"Used for code formatting output","package":"prettier","optional":false},{"reason":"Used in CLI for file watching","package":"chokidar","optional":true}],"imports":[{"note":"Plugin is exported as default export. CommonJS require works but TypeScript users should use default import.","wrong":"const reflow = require('babel-plugin-reflow')","symbol":"default","correct":"import reflow from 'babel-plugin-reflow'"},{"note":"ReflowError is a named export, not default.","wrong":"import ReflowError from 'babel-plugin-reflow'","symbol":"ReflowError","correct":"import { ReflowError } from 'babel-plugin-reflow'"},{"note":"Plugin name in Babel config is the full package name.","wrong":"{\n  \"plugins\": [\"reflow\"]\n}","symbol":"plugin","correct":"// .babelrc\n{\n  \"plugins\": [\"babel-plugin-reflow\"]\n}"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-reflow\n// Run CLI on src directory, replace .js with .ts in-place:\n// npx reflow --replace src/\n// Or with dry run:\n// npx reflow -d src/\n// Programmatic usage:\nconst reflow = require('babel-plugin-reflow');\nconst babel = require('@babel/core');\nconst code = `\n// @flow\nfunction greet(name: string): string {\n  return 'Hello, ' + name;\n}\n`;\nconst result = babel.transformSync(code, {\n  plugins: [reflow],\n  filename: 'input.js',\n});\nconsole.log(result.code);\n// Output:\n// function greet(name: string): string {\n//   return 'Hello, ' + name;\n// }","lang":"javascript","description":"Demonstrates CLI usage to transpile a directory and programmatic usage with Babel."},"warnings":[{"fix":"Manually replace `object` with `{}` in generated code if `{}` semantics required.","message":"Empty Flow object types `{}` are transformed to `object` instead of `{}` since v0.5.0.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Use `--exclude-patterns '**/node_modules/**'` instead.","message":"The `--exclude-dirs` option is deprecated in favor of `--exclude-patterns`.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Audit uses of `mixed` and add type guards or assertions as needed.","message":"Flow's `mixed` type is transformed to `unknown` in TypeScript; this may not be type-safe for codebases relying on dynamic access.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Review generated types for exact object semantics and add `Readonly` or `as const` as needed.","message":"Function type inference may differ: Flow's exact object types may become less precise.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Manually replace with TypeScript equivalents or suppress errors.","message":"Plugin does not handle `$ReadOnlyArray`, `$ReadOnly`, `$Exact` utilities; they may cause errors.","severity":"warning","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev babel-plugin-reflow` or `yarn add --dev babel-plugin-reflow`.","cause":"Package not installed or not in node_modules.","error":"Error: Could not find plugin 'babel-plugin-reflow'"},{"fix":"Add `@babel/preset-flow` to your Babel presets before the Reflow plugin.","cause":"File contains Flow syntax but Babel is not configured to parse Flow first.","error":"SyntaxError: Unexpected token (1:10) (While processing: ...)"},{"fix":"Either adjust TypeScript config to allow `object` or manually replace `object` with `{}`.","cause":"Reflow v0.5+ converts empty object `{}` to `object` which is not compatible.","error":"TypeScript error: Type 'object' is not assignable to type '{}'"},{"fix":"Replace `--exclude-dirs` with `--exclude-patterns` and update the pattern syntax.","cause":"Using deprecated CLI option.","error":"Error: Unknown option 'exclude-dirs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}