{"id":13661067,"url":"https://github.com/bcherny/flow-to-typescript","last_synced_at":"2025-04-05T03:02:19.074Z","repository":{"id":48018944,"uuid":"112444565","full_name":"bcherny/flow-to-typescript","owner":"bcherny","description":"Convert Flow-annotated files to TypeScript","archived":false,"fork":false,"pushed_at":"2022-12-06T19:59:19.000Z","size":509,"stargazers_count":430,"open_issues_count":19,"forks_count":43,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-01-25T09:25:10.717Z","etag":null,"topics":["compiler","flow","flowtype","javascript","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"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/bcherny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-29T07:56:14.000Z","updated_at":"2024-07-06T20:46:12.000Z","dependencies_parsed_at":"2023-01-23T12:30:21.573Z","dependency_job_id":null,"html_url":"https://github.com/bcherny/flow-to-typescript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Fflow-to-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Fflow-to-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Fflow-to-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Fflow-to-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcherny","download_url":"https://codeload.github.com/bcherny/flow-to-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280190,"owners_count":20912966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["compiler","flow","flowtype","javascript","typescript"],"created_at":"2024-08-02T05:01:29.323Z","updated_at":"2025-04-05T03:02:19.047Z","avatar_url":"https://github.com/bcherny.png","language":"TypeScript","readme":"# Flow-to-TypeScript [![Build Status][build]](https://circleci.com/gh/bcherny/flow-to-typescript) [![npm]](https://www.npmjs.com/package/flow-to-typescript) [![mit]](https://opensource.org/licenses/MIT)\n\n[build]: https://img.shields.io/circleci/project/bcherny/flow-to-typescript.svg?branch=master\u0026style=flat-square\n[npm]: https://img.shields.io/npm/v/flow-to-typescript.svg?style=flat-square\n[mit]: https://img.shields.io/npm/l/flow-to-typescript.svg?style=flat-square\n\n\u003e Compile Flow files to TypeScript\n\n**In Pre-Alpha - contributions welcome.**\n\n## Installation\n\n```sh\n# Using Yarn:\nyarn add flow-to-typescript\n\n# Or, using NPM:\nnpm install flow-to-typescript --save\n```\n\n## Usage\n\n### CLI\n\n```sh\n# Install globally\nyarn global add flow-to-typescript\n\n# Compile a file (all of these are equivalent)\nflow2ts my/file.js.flow\nflow2ts my/file.js.flow my/file.ts\nflow2ts my/file.js.flow \u003e my/file.ts\nflow2ts -i my/file.js.flow -o my/file.ts\nflow2ts --input my/file.js.flow --output my/file.ts\n```\n\n### Programmatic\n\n```js\nimport { compile } from 'flow-to-typescript'\nimport { readFileSync, writeFileSync } from 'fs'\n\nlet path = 'path/to/file.js.flow'\nlet file = readFileSync(path, 'utf-8')\n\ncompile(file, path).then(ts =\u003e\n  writeFileSync('path/to/file.ts', ts)\n)\n```\n\n## TypeScript vs. Flow\n\n### Features\n\n| Done? |             | Flow                                    | TypeScript |\n|-------|-------------|-----------------------------------------|------------|\n|   ✅  | Maybe       | `?type` (NullableTypeAnnotation)        | `type \\| null \\| undefined` |\n|   ✅  | Null        | `null`                                  | `null` |\n|   ✅  | Undefined   | `typeof undefined`                      | `undefined` |\n|   ✅  | Mixed       | `mixed`                                 | `unknown` |\n|   ✅  | Void        | `void`                                  | `void` |\n|   ✅  | Functions   | `(A, B) =\u003e C`                           | `(a: A, b: B) =\u003e C` |\n|   ⚔  | Predicates (0) | `(a: A, b: B) =\u003e %checks`            | `(a: A, b: B) =\u003e C` |\n|   ⚔  | Predicates (1) | `(a: A, b: B) =\u003e C %checks`          | `(a: A, b: B) =\u003e C` |\n|   ✅  | Exact types | `{\\| a: A \\|}`                            | `{ a: A }` |\n|   ✅  | Indexers    | `{ [A]: B }`                            | `{ [a: A]: B }` |\n|   ✅  | Opaque types | `opaque type A = B`                    | `type A = B` (not expressible) |\n|   ✅  | Variance    | `interface A { +b: B, -c: C }`          | `interface A { readonly b: B, c: C }` |\n|   ✅  | Bounds      | `\u003cA: string\u003e`                           | `\u003cA extends string\u003e` |\n|   ✅  | Casting     | `(a: A)`                                | `(a as A)` |\n|   ✅  | Import default type | `import type A from './b'`          | `import A from './b'` |\n|   ✅  | Import named type | `import type { A } from './b'`          | `import { A } from './b'` |\n\n### Utilities\n\n| Done? |             | Flow                                    | TypeScript |\n|-------|-------------|-----------------------------------------|------------|\n|       | Keys        | `$Keys\u003cA\u003e`                              | `keyof A` |\n|       | Values      | `$Values\u003cA\u003e`                            | `A[keyof A]` |\n|   ✅  | ReadOnly    | `$ReadOnly\u003cA\u003e`                          | `Readonly\u003cA\u003e` |\n|   ✅  | Exact       | `$Exact\u003cA\u003e`                             | `A` |\n|       | Difference  | `$Diff\u003cA, B\u003e`                           | TODO` |\n|       | Rest        | `$Rest\u003cA, B\u003e`                           | `Exclude` |\n|       | Property type | `$PropertyType\u003cT, k\u003e`                 | `T[k]` |\n|       | Element type | `$ElementType\u003cT, K\u003e`                   | `T[k]` |\n|       | Dependent type | `$ObjMap\u003cT, F\u003e`                      | TODO |\n|       | Mapped tuple | `$TupleMap\u003cT, F\u003e`                      | TODO |\n|       | Return type | `$Call\u003cF\u003e`                              | `ReturnType` |\n|       | Class       | `Class\u003cA\u003e`                              | `typeof A` |\n|       | Supertype   | `$Supertype\u003cA\u003e`                         | `any` (warn - vote for https://github.com/Microsoft/TypeScript/issues/14520) |\n|       | Subtype     | `$Subtype\u003cA\u003e`                           | `B extends A` |\n|       | Existential type | `*`                                | `any` (warn - vote for https://github.com/Microsoft/TypeScript/issues/14466) |\n\n\n✅ Done\n\n⚔ Babylon doesn't support it (yet)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Fflow-to-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcherny%2Fflow-to-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Fflow-to-typescript/lists"}