babel-plugin-transform-flow-comments

Turn flow type annotations into comments

MIT 29 个版本
安装
npm install babel-plugin-transform-flow-comments
yarn add babel-plugin-transform-flow-comments
pnpm add babel-plugin-transform-flow-comments
bun add 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"]
});
版本列表
7.0.0-beta.3 2017-10-15
7.0.0-beta.2 2017-09-26
7.0.0-beta.1 2017-09-19
7.0.0-beta.0 2017-09-12
7.0.0-alpha.20 2017-08-30
7.0.0-alpha.19 2017-08-07
7.0.0-alpha.18 2017-08-03
7.0.0-alpha.17 2017-07-26
7.0.0-alpha.16 2017-07-25
7.0.0-alpha.15 2017-07-12
7.0.0-alpha.14 2017-07-12
7.0.0-alpha.12 2017-05-31
7.0.0-alpha.11 2017-05-31
7.0.0-alpha.10 2017-05-25
7.0.0-alpha.9 2017-04-18
7.0.0-alpha.8 2017-04-17
7.0.0-alpha.7 2017-04-05
7.0.0-alpha.3 2017-03-23
7.0.0-alpha.1 2017-03-02
6.22.0 2017-01-20
6.21.0 2016-12-16
6.17.0 2016-10-01
6.8.0 2016-05-02
6.7.0 2016-03-09
6.6.0 2016-02-29
6.5.0-1 2016-02-07
6.5.0 2016-02-07
6.4.0 2016-01-06
6.3.23 2015-12-18