Converts Flow declarations to TypeScript.
It is focused to work with code specially written for Flowest, not some random Flow code.
You can install js_of_ocaml version via npm:
$ npm install -D flowest
# Or: $ npm install --global flowest
Flowest can also be compiled to native code.
You can manually build it from the source code (it should work much faster).
$ flowest <input-file> <output-file>
# Or: $ npx flowest <input-file> <output-file>
It supports raw TypeScript via /*$$ ... */
:
type A = string
/*$$
type B = Partial<{ a: A, b: number }>
*/
/*::
type C = 3
*/
Output:
type A = string
type B = Partial<{ a: A, b: number }>
type C = 3
flowest-remove-next-line
and flowest-remove-line
:
/*$$ export type Id = unknown */
// flowest-remove-next-line
export opaque type Id = string
Output:
export type Id = unknown
- โ - Done
- ๐ฉ - Not fully correct
Status | Name | Flow | TypeScript |
---|---|---|---|
โ | Maybe | ?T |
T | null | undefined |
โ | Null | null |
null |
โ | Mixed | mixed |
unknown |
โ | Void | void |
void ๐ฉ |
BigInt | type A = 2n |
type A = 2n |
|
โ | Union | A | B | C |
A | B | C |
โ | Intersection | A & B & C |
A & B & C |
โ | Typeof | typeof T |
typeof T |
โ | Tuples | [T, U] |
[T, U] |
โ | Functions | (A, B) => C |
(a: A, b: B) => C |
โ | Predicates | (A, B) => C %checks |
(a: A, b: B) => C ๐ฉ |
โ | Inexact types | { a: A, ... } or { a: A } |
{ a: A } ๐ฉ |
โ | Exact types | {| a: A |} |
{ a: A } ๐ฉ |
โ | Existential types | * |
any (not expressible) ๐ฉ |
โ | Indexers | { [K]: T } |
{ [key: K]: T } |
โ | Bounds | <T: string> |
<T extends string> |
โ | Read-only fields | interface A { +b: B } |
interface A { readonly b: B } |
โ | Write-only fields | interface A { -c: C } |
interface A { c: C } ๐ฉ |
Inline interfaces | type T = interface { a: A } |
- | |
Spread properties | { a: A, ...O } |
{ a: A } & O ๐ฉ |
|
Internal slots | { [[call]]: T => U } |
- | |
โ | Partial | $Rest<T, {}> |
Partial<T> |
$Shape | $Shape<T> |
- (not expressible) | |
โ | $ReadOnly | $ReadOnly<T> |
Readonly<T> |
โ | $Keys | $Keys<T> |
keyof T |
โ | $Values | $Values<T> |
T[keyof T] |
โ | $Exact | $Exact<T> |
T ๐ฉ |
โ | Class | Class<T> |
typeof T |
โ | Property type | $PropertyType<O, k> |
O[k] |
โ | Element type | $ElementType<T, K> |
T[K] |
โ | Return type | $Call<F> |
ReturnType<F> |
$Call | $Call<F, A1, A2, ..., Ak> |
- (not expressible) | |
$Diff | $Diff<T, U> |
Pick<T, Exclude<keyof T, keyof U>> ๐ฉ |
|
$Rest | $Rest<T, U> |
- | |
$ObjMap | $ObjMap<T, <X>(X) => X> |
{ [P in keyof T]: T[P] } |
|
$ObjMapi | $ObjMapi<T, <I>(I) => I> |
{ [I in keyof T]: I } |
|
$TupleMap | $TupleMap<T, <X>(X) => X> |
{ [P in keyof T]: T[P] } |
|
โ | $NonMaybeType | $NonMaybeType<T> |
NonNullable<T> ๐ฉ |
$CharSet | $CharSet<"abc"> |
- (not expressible) | |
$Trusted | $Trusted<T> |
- (not expressible) | |
$Private | $Private<T> |
- (not expressible) |
Status | Name | Flow | TypeScript |
---|---|---|---|
โ | Import default type | import type T from './b' |
import T from './b' |
โ | Import named type | import type { T } from './b' |
import { T } from './b' |
โ | Export type | export type { T } |
export { T } |
โ | Declare export | declare export class Cl {} |
export declare class Cl {} |
Declare export default | declare export default string |
- | |
Declare module | declare module 'm' { } |
- | |
Declare module exports | declare module.exports: T |
- | |
โ | Type alias | type T = string |
type T = string |
โ | Declare type alias | declare type T = string |
declare type T = string |
โ | Interface | interface I extends A, B {} |
interface I extends A, B {} |
โ | Declare interface | declare interface I {} |
declare interface I {} |
Opaque type | opaque type T = string |
- | |
Declare opaque type | declare opaque type T = string |
- | |
โ | Declare variable | declare var a: number |
declare var a: number |
โ | Declare function | declare function f(string): number |
declare function f(a: string): number |
โ | Declare class | declare class B<T, U = D> extends A implements I1, I2 {} |
the same |
mixins in declare class |
declare class B mixins A {} |
- |
Status | Name | Flow | TypeScript |
---|---|---|---|
โ | $ReadOnlyArray | $ReadOnlyArray<T> |
ReadonlyArray<T> |
โ | $ReadOnlyMap | $ReadOnlyMap<K, V> |
ReadonlyMap<K, V> |
โ | $ReadOnlySet | $ReadOnlySet<T> |
ReadonlySet<T> |
Iterator | - | - | |
Iterable | - | - | |
AsyncInterator | - | - | |
AsyncInterable | - | - | |
Generator | - | - | |
AsyncGenerator | - | - |
You can manually write TS code inside /*$$ ... */
for a feature that is not supported.
Supported version of Flow parser: 0.96.1