1.0.16 • Published 5 years ago

flow-to-ts v1.0.16

Weekly downloads
211
License
ISC
Repository
github
Last release
5 years ago

Intro

Converts flow files to ts using jscodeshift. It isn't perfect, but should get you pretty close. There are a couple of fundamental differences that have to be manually converted.

Usage

$ npx flow-to-ts -o ts /path/to/flow/files # Will convert .js files into .ts files

If you're going to be using this tool a couple of times, it's probably best not to use npx since it will reinstall everything everytime you run it.

instead use npm install -g flow-to-ts

Advanced Usage

.js files with jsx

$ npx flow-to-ts -o tsx /path/to/flow/files # Will convert .js files into .tsx files

.jsx files

$ npx flow-to-ts -o tsx /path/to/flow/files # Will convert .jsx files into .tsx files

.js.flow files

$ npx flow-to-ts -o d.ts /path/to/flow/files # Will convert .js.flow files into .d.ts files

Dry Mode and passing arguments to jscodeshift

Everything after -- will be forwarded to jscodeshift cli

$ npx flow-to-ts -o ts /path/to/flow/files -- --dry # Won't change code

Fundamental Differences

.js.flow vs .d.ts

In flow, definition files (.js.flow) are looked at with higher precedence over .js files. The reverse is true for typescript.

This is a problem if you do something like: "import {type Foo} from 'foo'" and there exists foo.js and foo.js.flow. You'll have to manually restructure your code.

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago