Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Convert Flow-annotated files to TypeScript

License

NotificationsYou must be signed in to change notification settings

mohsen1/flow-to-typescript

 
 

Repository files navigation

Compile Flow files to TypeScript

In Pre-Alpha - contributions welcome.

Installation

# Using Yarn:yarn add flow-to-typescript# Or, using NPM:npm install flow-to-typescript --save

Usage

CLI

# Install globallyyarn global add flow-to-typescript# Compile a file (all of these are equivalent)flow2ts my/file.js.flowflow2ts my/file.js.flow my/file.tsflow2ts my/file.js.flow> my/file.tsflow2ts -i my/file.js.flow -o my/file.tsflow2ts --input my/file.js.flow --output my/file.ts

Programmatic

import{compile}from'flow-to-typescript'import{readFileSync,writeFileSync}from'fs'letpath='path/to/file.js.flow'letfile=readFileSync(path,'utf-8')compile(file,path).then(ts=>writeFileSync('path/to/file.ts',ts))

TypeScript vs. Flow

Features

Done?FlowTypeScript
Maybe?type (NullableTypeAnnotation)type | null | undefined
Nullnullnull
Undefinedtypeof undefinedundefined
Mixedmixedunknown
Voidvoidvoid
Functions(A, B) => C(a: A, b: B) => C
Predicates (0)(a: A, b: B) => %checks(a: A, b: B) => C
Predicates (1)(a: A, b: B) => C %checks(a: A, b: B) => C
Exact types{| a: A |}{ a: A }
Indexers{ [A]: B }{ [a: A]: B }
Opaque typesopaque type A = Btype A = B (not expressible)
Varianceinterface A { +b: B, -c: C }interface A { readonly b: B, c: C }
Bounds<A: string><A extends string>
Casting(a: A)(a as A)
Import default typeimport type A from './b'import A from './b'
Import named typeimport type { A } from './b'import { A } from './b'

Utilities

Done?FlowTypeScript
Keys$Keys<A>keyof A
Values$Values<A>A[keyof A]
ReadOnly$ReadOnly<A>Readonly<A>
Exact$Exact<A>A
Difference$Diff<A, B>TODO`
Rest$Rest<A, B>Exclude
Property type$PropertyType<T, k>T[k]
Element type$ElementType<T, K>T[k]
Dependent type$ObjMap<T, F>TODO
Mapped tuple$TupleMap<T, F>TODO
Return type$Call<F>ReturnType
ClassClass<A>typeof A
Supertype$Supertype<A>any (warn - vote formicrosoft/TypeScript#14520)
Subtype$Subtype<A>B extends A
Existential type*any (warn - vote formicrosoft/TypeScript#14466)

✅ Done

⚔ Babylon doesn't support it (yet)

About

Convert Flow-annotated files to TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript90.7%
  • JavaScript9.3%

[8]ページ先頭

©2009-2025 Movatter.jp