bcherny / Flow To Typescript
Licence: mit
Convert Flow-annotated files to TypeScript
Stars: ✭ 425
Programming Languages
javascript
184084 projects - #8 most used programming language
typescript
32286 projects
flow
126 projects
flowtype
47 projects
Labels
Projects that are alternatives of or similar to Flow To Typescript
Cingulata
Cingulata (pronounced "tchingulata") is a compiler toolchain and RTE for running C++ programs over encrypted data by means of fully homomorphic encryption techniques.
Stars: ✭ 369 (-13.18%)
Mutual labels: compiler
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+1132.47%)
Mutual labels: compiler
Ilgpu
ILGPU JIT Compiler for high-performance .Net GPU programs
Stars: ✭ 374 (-12%)
Mutual labels: compiler
Sericum
(Toy) Compiler Infrastructure influenced by LLVM written in Rust
Stars: ✭ 366 (-13.88%)
Mutual labels: compiler
Nuitka
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
Stars: ✭ 6,173 (+1352.47%)
Mutual labels: compiler
Trunk
Build, bundle & ship your Rust WASM application to the web.
Stars: ✭ 378 (-11.06%)
Mutual labels: compiler
Compiler series
Material for the Creating a Compiler video lesson series.
Stars: ✭ 409 (-3.76%)
Mutual labels: compiler
Mini C
Dr Strangehack, or: how to write a self-hosting C compiler in 10 hours
Stars: ✭ 372 (-12.47%)
Mutual labels: compiler
Wax
A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly 🚀
Stars: ✭ 373 (-12.24%)
Mutual labels: compiler
Phalanger
PHP 5.4 compiler for .NET/Mono frameworks. Predecessor to the opensource PeachPie project (www.peachpie.io).
Stars: ✭ 369 (-13.18%)
Mutual labels: compiler
Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (-13.65%)
Mutual labels: compiler
Scala Native
Your favorite language gets closer to bare metal.
Stars: ✭ 4,053 (+853.65%)
Mutual labels: compiler
Bytecoder
Rich Domain Model for JVM Bytecode and Framework to interpret and transpile it.
Stars: ✭ 401 (-5.65%)
Mutual labels: compiler
Flow-to-TypeScript
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 globally
yarn global add flow-to-typescript
# Compile a file (all of these are equivalent)
flow2ts my/file.js.flow
flow2ts my/file.js.flow my/file.ts
flow2ts my/file.js.flow > my/file.ts
flow2ts -i my/file.js.flow -o my/file.ts
flow2ts --input my/file.js.flow --output my/file.ts
Programmatic
import { compile } from 'flow-to-typescript'
import { readFileSync, writeFileSync } from 'fs'
let path = 'path/to/file.js.flow'
let file = readFileSync(path, 'utf-8')
compile(file, path).then(ts =>
writeFileSync('path/to/file.ts', ts)
)
TypeScript vs. Flow
Features
Done? | Flow | TypeScript | |
---|---|---|---|
✅ | Maybe |
?type (NullableTypeAnnotation) |
type | null | undefined |
✅ | Null | null |
null |
✅ | Undefined | typeof undefined |
undefined |
✅ | Mixed | mixed |
unknown |
✅ | Void | void |
void |
✅ | 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 types | opaque type A = B |
type A = B (not expressible) |
✅ | Variance | interface 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 type | import type A from './b' |
import A from './b' |
✅ | Import named type | import type { A } from './b' |
import { A } from './b' |
Utilities
Done? | Flow | TypeScript | |
---|---|---|---|
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 |
|
Class | Class<A> |
typeof A |
|
Supertype | $Supertype<A> |
any (warn - vote for https://github.com/Microsoft/TypeScript/issues/14520) |
|
Subtype | $Subtype<A> |
B extends A |
|
Existential type | * |
any (warn - vote for https://github.com/Microsoft/TypeScript/issues/14466) |
✅ Done
⚔ Babylon doesn't support it (yet)
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].