Not Particularly Meaningful
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

flow-typestrip

0.1.3 • Public • Published

flow-typestrip Build Status

flow-typestrip is a recast based transform to remove Flow type annotations from typed JavaScript code, so that the code can be executed in JavaScript environments.

Alternatives: react-tools also strips type annotations. You should use it if you are also using React / JSX.

Install

$ npm install [-D] flow-typestrip

Usage

As a CLI

flow-typstrip comes with a command-line interface that can be used when installed globally. Here is how to convert a single file and print to stdout:

$ flow-typestrip source.js

To compile many files at once, specify an output directory:

$ flow-typestrip -o dist src/**/*.js

To enable source maps for this files, add the --source-maps flag.

As a library

var flowStrip = require('flow-typestrip');
var result = flowStrip.compile(source, {
  sourceFileName: 'example.js',
  sourceMapName: 'example.js.map'
});
 
fs.writeFileSync('result.js', result.code);
fs.writeFileSync('result.js.map', JSON.stringify(result.map));

With browserify

flow-typestrip can directly be used with browserify:

$ browserify -t flow-typestrip script.js

Development

If you look at the main transform function, it is very simple. To ensure that the types are stripped correctly, I'm using the unit tests from jstransform.

Acknowledgments

install

npm i flow-typestrip

Downloadsweekly downloads

8

version

0.1.3

license

none

last publish

collaborators

  • avatar
Report a vulnerability