{"id":13683052,"url":"https://github.com/stripe-archive/flow-to-typescript-codemod","last_synced_at":"2026-01-18T09:58:33.089Z","repository":{"id":37738657,"uuid":"476801215","full_name":"stripe-archive/flow-to-typescript-codemod","owner":"stripe-archive","description":"Codemod Stripe used to migrate 6.5m+ lines of code from Flow to TypeScript","archived":false,"fork":false,"pushed_at":"2025-04-11T22:13:12.000Z","size":177,"stargazers_count":696,"open_issues_count":0,"forks_count":73,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-10-10T05:42:41.485Z","etag":null,"topics":["codemod","flow","migration","typescript"],"latest_commit_sha":null,"homepage":"https://stripe.com/blog/migrating-to-typescript","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stripe-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-04-01T16:52:50.000Z","updated_at":"2025-10-07T10:50:50.000Z","dependencies_parsed_at":"2024-01-14T15:24:21.636Z","dependency_job_id":"7cd5693c-f3c5-452c-8b45-8dacca124566","html_url":"https://github.com/stripe-archive/flow-to-typescript-codemod","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stripe-archive/flow-to-typescript-codemod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-archive%2Fflow-to-typescript-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-archive%2Fflow-to-typescript-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-archive%2Fflow-to-typescript-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-archive%2Fflow-to-typescript-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stripe-archive","download_url":"https://codeload.github.com/stripe-archive/flow-to-typescript-codemod/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-archive%2Fflow-to-typescript-codemod/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codemod","flow","migration","typescript"],"created_at":"2024-08-02T13:01:58.691Z","updated_at":"2026-01-18T09:58:33.074Z","avatar_url":"https://github.com/stripe-archive.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg\n    src=\"./llama.png\"\n    alt=\"TypeScript Llama\"\n    width=\"160px\"\n  /\u003e\n  \u003ch1\u003eFlow to TypeScript Codemod\u003c/h1\u003e\n  \u003cbr /\u003e\n\u003c/div\u003e\n\n\u003e \u003cimg src=\"https://stripe.dev/images/badges/archived.png\" width=\"250\"\u003e\n\u003e\n\u003e This project is provided as-is and is not actively maintained.\n\nFor more background on Stripe's TypeScript migration, check out our [blog post](https://stripe.com/blog/migrating-to-typescript)!\n\nThis is the codemod Stripe used to migrate 4m+ lines of [Flow](https://flow.org/en/) to [TypeScript](https://www.typescriptlang.org/).\nIt has a few commands to automate the separate steps of a migration:\n\n- `setup` - Tools for installing TypeScript and type declarations in a project.\n- `convert` - The main codemod, which uses Babel to convert files from Flow to TypeScript.\n- `fix` - A second codemod that uses [ts-morph](https://github.com/dsherret/ts-morph) to find, fix, suppress, and report TypeScript errors after initial conversion.\n\nEvery codebase and migration will be slightly different, so we recommend forking this repository and modifying it as needed for your use case. Our applications are written in React, so other frameworks will need additional work to support.\n\n\u003e **Note**: We also recommend being on a version of Flow higher than `v0.92.1`, for best support retrieving missing types from Flow. Newer versions of Flow will work better.\n\n## 🚀 Quick start\n\nTo try out this codemod on your codebase, you'll want to clone this repository and build the tool. We used `yarn` for package management but others should work as long as the patch packages are applied.\n\n```bash\n# Clone the repository\ngit clone https://github.com/stripe-archive/flow-to-typescript-codemod.git\ncd flow-to-typescript-codemod/\n\n# Install dependencies\nyarn\n\n# Run on a folder\nyarn typescriptify convert -p ../path/to/your/codebase # Run in 'dry-run' without writing files\nyarn typescriptify convert -p ../path/to/your/codebase --write --delete # Write converted files and delete Flow source\n\n# Suppress errors\nyarn typescriptify fix --autoSuppressErrors -p ../path/to/your/codebase --config ../path/to/your/codebase/tsconfig.json\n\n```\n\n\u003e **Note**: You can publish this package or link it using a workspace management tool to install it into multiple projects.\n\n## 🔨 Basic usage\n\nThe main command for the project is `typescriptify`, and there are three sub-commands:\n\n```\ntypescriptify [command]\n\nCommands:\n  typescriptify setup    Set your project up to support TypeScript.\n  typescriptify convert  Convert Flow-typed files to TypeScript.\n  typescriptify fix      Use the TypeScript compiler to identify and fix errors.\n\nOptions:\n  --version  Show version number\n  --help     Show help\n\nExamples:\n  typescriptify \u003csetup,convert,fix\u003e --help                                         Show usage instructions for a specific command.\n  typescriptify convert --path .                                                   Run the codemod in dry-run mode.\n  typescriptify convert --path src/ test/                                          Run the codemod on multiple paths.\n  typescriptify convert --path . --ignore flow_typed/                              Ignore files from conversion.\n  typescriptify convert --path ./src --format csv --output ./migration-report.csv  Generate a CSV migration report.\n  typescriptify convert --path . --write --delete                                  Fully convert a project to TypeScript,\n                                                                                   writing files and deleting Flow files.\n  typescriptify convert --path . --write --target=./dist                           Specify a directory to output the TypeScript files.\n  typescriptify fix --autoSuppressErrors --removeUnused                            Remove unused ts-expect-errors, and add any for current errors.\n  typescriptify fix --autoSuppressErrors --jiraSlug JIRA-722                       Suppress errors but add a JIRA slug to the comments.\n  typescriptify fix --generateReport --output ./migration-report.csv               Generate a CSV file of categorized TS errors.\n```\n\n## 🏃 Running conversions from Flow to TypeScript\n\n### Dry run\n\nBy default, the codemod will run a dry run against your codebase. This mode will not actually write any TypeScript files, but will collect any potential problems in the Flow code that you may want to investigate prior to doing the actual conversion:\n\n```bash\nyarn typescriptify convert --path \u003cpath to source directory\u003e\n```\n\n### Running the conversion\n\nOnce you are ready to generate the actual TypeScript files, add the `--write` argument. This will generate new `.ts` and `.tsx` files from existing Flow files, and will leave the Flow files intact. In order to remove the Flow files as well, add the `--delete` argument.\n\n```bash\n# By default, this will leave your Flow files intact:\nyarn typescriptify convert --write --path \u003cpath to source directory\u003e\n\n# If you want to delete the Flow files, and leave only the TypeScript files, add --delete\nyarn typescriptify convert --write --delete --path \u003cpath to source directory\u003e\n\n# If you want to specify a different directory to emit the TS files add --target\nyarn typescriptify convert --write --path \u003cpath to source directory\u003e --target \u003cwhere the source files should go\u003e\n```\n\n### Utility types\n\nIn cases where the conversion requires a complicated type, the codemod will insert an import for utility types:\n\n```ts\nimport {Flow} from 'flow-to-typescript-codemod';\nFlow.Diff\u003cA, B\u003e;\n```\n\nThese types are defined in `./flow.d.ts`, and you'll need to do some setup to make the import work. At Stripe, we published a version of this package internally so it could be installed in each codebase and the types would be available. You could also copy `flow.d.ts` into your project and use [paths](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) to resolve the import.\n\n## 📌 Advanced usage\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to expand!\u003c/summary\u003e\n  \n### Automatically suppressing TypeScript errors\nAfter conversion, there will likely be a number of errors in the converted TypeScript files. These errors can be the result of pre-existing issues in the Flow code, issues with the installed types, or issues with the codemod. For many conversions, the number of errors may be challenging to fix before merging. The auto suppression feature will run the TypeScript compiler against your converted code, and add [ts-expect-error](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#ts-ignore-or-ts-expect-error) annotations that suppress errors. This allows you to suppress the errors to get a passing type check, and then fix the errors in future changes. If you fix an error that fixes other errors, you can use the `removeUnused` flag to automatically remove unused suppressions.\n\n```bash\nyarn typescriptify fix --autoSuppressErrors --jiraSlug \u003cslug i.e JIRA-722\u003e\n```\n\n### Auto-generating declarations\n\nIf you want to continue writing Flow, but generate additional TypeScript versions, you can use the watermarking flag. Adding the `--watermark` argument will add a watermark to every file:\n\n```bash\nyarn typescriptify convert --watermark --path \u003cpath to source directory\u003e\n```\n\nYou can configure the codemod to skip files without a watermark when doing future conversions. Remove the watermark from a file to make manual edits to the type.\n\n### Supporting prop spreads\n\nIf your codebase follows the pattern of accepting any prop, and then forwarding them to another component like this:\n\n```ts\nconst MyComponent = (props: Props) =\u003e {\n  const { myProp, ...rest } = props;\n  return \u003cAnotherComponent test={myProp} {...rest} /\u003e;\n};\n```\n\nFlow was likely typing your extra parameters as `any`, and those will be type failures in TypeScript.\nWe have experimental support for updating prop types to include the props of the underlying HTML element or component.\nAdd the `--handleSpreadReactProps` to turn on this transformation.\n\n\u003c/details\u003e\n\n## 💻 Developing\n\n```bash\n# Install dependencies\nyarn\n# Run on a folder\nyarn typescriptify convert -p ../path/to/your/codebase\n# Build\nyarn build\n# Run tests\nyarn test\n# Type-check\nyarn types\n# Lint\nyarn lint\n```\n\n## 📝 Notes\n\nWe've compiled our [notes](NOTES.md) documenting the complex type conversions.\n\n## 🎨 Prior art\n\nThis project was built on top of [Airtable's TypeScript Codemod](https://github.com/Airtable/typescript-migration-codemod).\nWe're thankful for the Airtable team ([Caleb Meredith](https://github.com/calebmer) and [Andrew Wang](https://github.com/umbrant)) for open-sourcing their work, and hope others can similarly benefit from our project.\n\n## 📎 License\n\nThis project uses the [MIT license](LICENSE).\n\n## Thanks\n\nThank you to the developers at Pinterest for [contributing some patches](https://github.com/stripe-archive/flow-to-typescript-codemod/pull/7) from their migration!\n\n## ✨ Contributing\n\nThis project is not being actively maintained. Please feel free to fork this repository to add changes as needed. Every migration will have some different patterns that need special logic, so it would be hard to maintain any general purpose tool for this task. That said, if you complete a migration and would like to contribute some work back feel free to open a PR and we'll look at it if we have time. Thanks!\n\nIf you have questions about this code or our migration, you can reach out to members of our team:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/tylerkrupicka\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/5761061?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTyler Krupicka\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/ken-kenware\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/3946841?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKen Deland\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/RussGlover\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/90730502?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRussill Glover\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/benbayard\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1026035?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBen Bayard\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/alunny\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/48361?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAndrew Lunny\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe-archive%2Fflow-to-typescript-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstripe-archive%2Fflow-to-typescript-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe-archive%2Fflow-to-typescript-codemod/lists"}