bpt
babel-plugin-typescript-to-flow
npm i babel-plugin-typescript-to-flow
bpt

babel-plugin-typescript-to-flow

utility script to convert project from flow to typescript

by Bogdan Savluk

0.15.20 (see all)License:MITTypeScript:Built-In
npm i babel-plugin-typescript-to-flow
Readme

babel-plugin-typescript-to-flow

Babel plugin to convert TypeScript code into Flow

If you are looking for converting .d.ts files to Flow definitions - be sure check flowgen first.

Usage

Most convenient - via tsflow utility, which currently is part of flowts.

Usage as babel plugin:

Installation:

npm install babel-plugin-typescript-to-flow

Plugin options:

{
  // should be true when source code is from `d.ts` file
  isAmbientContext: boolean 
}

Why?

While main goal of this repository is to do the opposite (to help migrate from Flow to TypeScript), in many cases it is preferable to do so gradually.

Especially when having multiple other projects depending on support for Flow. To do so there is a need to generate Flow type definitions from TypeScript .d.ts files.

Why not flowgen:

  • this should be similar to "flow to typescript", and so - keeping it simpler.
  • because this plugin manipulates AST instead of generating the text directly - there is a bit more flexibility about what is possible.

However, flowgen does wonderful job converting the definitions files. There are probably cases where it currently does better job comparing to this plugin.

Purpose

The focus is on converting .d.ts files.

However, it is not limited to only definition files, and a lot of features already are supported.

Status

Still work in progress. Some features are missing.

For the test cases that might be not covered - check test folder, there are some skipped test cases, to be implemented.

Downloads/wk

124

GitHub Stars

70

LAST COMMIT

8mos ago

MAINTAINERS

1

CONTRIBUTORS

12

OPEN ISSUES

19

OPEN PRs

0
VersionTagPublished
0.15.20
latest
10d ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate