Socket
Book a DemoInstallSign in
Socket

flow-typestrip

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-typestrip

A Recast based transform to remove Flow type annotations.

latest
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

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

Keywords

transformer

FAQs

Package last updated on 27 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts