🌜
🌞
babel-plugin-transform-flow-comments

babel-plugin-transform-flow-comments

v6.22.0

Turn flow type annotations into comments

npm install babel-plugin-transform-flow-comments

README

babel-plugin-transform-flow-comments

Turn flow type annotations into comments.

You should be able to use this plugin instead of babel-plugin-flow-strip-types to preserve the /* @flow */ directive and still use flow.

http://flowtype.org/blog/2015/02/20/Flow-Comments.html

Example

In

function foo(bar?) {}
function foo2(bar?: string) {}
function foo(x: number): string {}
type B = {
  name: string;
};
export type GraphQLFormattedError = number;
import type A, { B, C } from './types';
import typeof D, { E, F } from './types';

Out

"use strict";

function foo(bar /*:: ?*/) {}
function foo2(bar /*:: ?: string*/) {}
function foo(x /*: number*/) /*: string*/ {}
/*:: type B = {
  name: string;
};*/
/*:: export type GraphQLFormattedError = number;*/
/*:: import type A, { B, C } from './types';*/
/*:: import typeof D, { E, F } from './types';*/

Installation

$ npm install babel-plugin-transform-flow-comments

Usage

.babelrc

{
  "plugins": ["transform-flow-comments"]
}

Via CLI

$ babel --plugins transform-flow-comments script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-flow-comments"]
});

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
41.4K
Community Interest
42.9K
Number of Forks
5,455

Maintenance

Commits
10/219/22070
Last Commit
Open Issues
628
Closed Issues
7,633
Open Pull Requests
149
Closed Pull Requests
1,045

Versions

Versions Released
10/219/2201
Latest Version Released
Jan 20, 2017
Current Tags
latest6.22.0
next7.0.0-beta.3

Dependencies

Contributors

sebmck
sebmck
Commits: 5,195
hzoo
hzoo
Commits: 1,263
loganfsmyth
loganfsmyth
Commits: 594
nicolo-ribaudo
nicolo-ribaudo
Commits: 487
existentialism
existentialism
Commits: 460
danez
danez
Commits: 433
JLHwung
JLHwung
Commits: 283
marijnh
marijnh
Commits: 264
RReverser
RReverser
Commits: 233
jamiebuilds
jamiebuilds
Commits: 224
amasad
amasad
Commits: 172
jridgewell
jridgewell
Commits: 159
xtuc
xtuc
Commits: 105
yavorsky
yavorsky
Commits: 89
kaicataldo
kaicataldo
Commits: 81