Babel plugin to convert Flow into TypeScript
npm install babel-plugin-flow-to-typescript[Babel] plugin to convert [Flow] code into [TypeScript]
``shell
$ npm install -g @babel/cli @babel/core
$ npm install babel-plugin-flow-to-typescript
$ babel --plugins babel-plugin-flow-to-typescript ${SRC_FLOW_FILE} -o ${DEST_TS_FILE}
`
| Supported? | Syntax | Flow | TypeScript |
| ---------- | --------------------- | --------------------------------- | ----------------------------------------------- |
| ✅ | Maybe type | let a:?number | let a: number \| null \| undefined |void
| ✅ | Void type | | void |Object
| ✅ | Object type | | object |mixed
| ✅ | Mixed type | | unknown |(A, B) => C
| ✅ | Function type | | (x1: A, x2: B) => C |{\| a: A \|}
| ✅ | Exact type | | { a: A } |{ [A]: B }
| ✅ | Indexers | | { [a: A]: B } |Map<, >
| ✅ | Existential type | | Map |opaque type A = B
| ✅ | Opaque types | | type A = B |interface A { +b: B, -c: C }
| ✅ | Variance | | interface A { readonly b: B, c: C } |function f
| ✅ | Type parameter bounds | | function f(a:A){} |(a: A)
| ✅ | Cast | | (a as A) |import type A from 'module'
| ✅ | type/typeof import | | 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 foo
| ✅ | typeof operator | | typeof foo |[number, string]
| ✅ | JSX | - | - |
| ✅ | Tuple type | | [number, string] |type A = string
| ✅ | Type alias | | type A = string |$FlowFixMe
| ✅ | Flow Ignore | | any |interface X { +prop: string }
| ✅ | Interfaces | | interface X { readonly prop: string } |a?.b
| ✅ | Optional Members | | ... |declare function x(false): true;
| ✅ | Declare functions | | 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