Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiikurage/babel-plugin-flow-to-typescript
Babel plugin to convert Flow code into TypeScript
https://github.com/kiikurage/babel-plugin-flow-to-typescript
babel flow javascript typescript
Last synced: 25 days ago
JSON representation
Babel plugin to convert Flow code into TypeScript
- Host: GitHub
- URL: https://github.com/kiikurage/babel-plugin-flow-to-typescript
- Owner: Kiikurage
- License: mit
- Created: 2018-04-14T05:15:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:37:07.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T23:04:39.108Z (25 days ago)
- Topics: babel, flow, javascript, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/babel-plugin-flow-to-typescript
- Size: 841 KB
- Stars: 162
- Watchers: 7
- Forks: 33
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-flow-to-typescript
[Babel] plugin to convert [Flow] code into [TypeScript]
## How to use
```shell
$ npm install -g @babel/cli @babel/core
$ npm install babel-plugin-flow-to-typescript# you must use babel@^7.x.x
$ babel --version
7.4.4 (@babel/core 7.4.5)$ babel --plugins babel-plugin-flow-to-typescript ${SRC_FLOW_FILE} -o ${DEST_TS_FILE}
```## Implementation status
| Supported? | Syntax | Flow | TypeScript |
| ---------- | --------------------- | --------------------------------- | ----------------------------------------------- |
| ✅ | Maybe type | `let a:?number` | `let a: number \| null \| undefined` |
| ✅ | Void type | `void` | `void` |
| ✅ | Object type | `Object` | `object` |
| ✅ | Mixed type | `mixed` | `unknown` |
| ✅ | Function type | `(A, B) => C` | `(x1: A, x2: B) => C` |
| ✅ | Exact type | `{\| a: A \|}` | `{ a: A }` |
| ✅ | Indexers | `{ [A]: B }` | `{ [a: A]: B }` |
| ✅ | Existential type | `Map<*, *>` | `Map` |
| ✅ | Opaque types | `opaque type A = B` | `type A = B` |
| ✅ | Variance | `interface A { +b: B, -c: C }` | `interface A { readonly b: B, c: C }` |
| ✅ | Type parameter bounds | `function f(a:A){}` | `function f(a:A){}` |
| ✅ | Cast | `(a: A)` | `(a as A)` |
| ✅ | type/typeof import | `import type A from 'module'` | `import A from 'module'` |
| ✅ | \$Keys | `$Keys` | `keyof X` |
| ✅ | \$Values | `$Values` | `X[keyof X]` |
| ✅ | \$ReadOnly | `$Readonly` | `Readonly` |
| ✅ | \$Exact | `$Exact` | `X` |
| ✅ | \$Diff | `$Diff` | `Pick>` |
| ✅ | \$PropertyType | `$PropertyType` | `T[k]` |
| ✅ | \$ElementType | `$ElementType` | `T[k]` |
| ✅ | $Shape | `$Shape` | `Partial` |
| ✅ | Class | `Class` | `typeof T` |
| ✅ | typeof operator | `typeof foo` | `typeof foo` |
| ✅ | JSX | - | - |
| ✅ | Tuple type | `[number, string]` | `[number, string]` |
| ✅ | Type alias | `type A = string` | `type A = string` |
| ✅ | Flow Ignore | `$FlowFixMe` | `any` |
| ✅ | Interfaces | `interface X { +prop: string }` | `interface X { readonly prop: string }` |
| ✅ | Optional Members | `a?.b` | `...` |
| ✅ | Declare functions | `declare function x(false): true;`| `function x(x0: false): true;` |
| ✅ | Declare Class | `...` | `...` |[babel]: https://github.com/babel/babel
[flow]: https://github.com/facebook/flow
[typescript]: https://github.com/Microsoft/TypeScript