Giter Site home page Giter Site logo

flow-remove-types's Introduction

flow-remove-types

Turn your JavaScript with Flow type annotations into standard JavaScript in an instant with no configuration and minimal setup.

Flow provides static type checking to JavaScript which can both help find and detect bugs long before code is deployed and can make code easier to read and more self-documenting. The Flow tool itself only reads and analyzes code. Running code with Flow type annotations requires first removing the annotations which are non-standard JavaScript. Typically this is done via adding a plugin to your Babel configuration, however Babel may be overkill if you're only targetting modern versions of Node.js or just not using the modern ES2015 features that may not be in every browser.

flow-remove-types is a faster, simpler, zero-configuration alternative with minimal dependencies for super-fast npm install time.

Get Started!

Use the command line:

npm install --global flow-remove-types
flow-remove-types --help
flow-remove-types input.js > output.js

Or the JavaScript API:

npm install flow-remove-types
var flowRemoveTypes = require('flow-remove-types');
var fs = require('fs');

var input = fs.readFileSync('input.js', 'utf8');
var output = flowRemoveTypes(input);
fs.writeFileSync('output.js', output);

Dead-Simple Transforms

When flow-remove-types removes Flow types, it replaces them with whitespace. This ensures that the transformed output has exactly the same number of lines and characters and that all character offsets remain the same. This removes the need for sourcemaps, maintains legible output, and ensures that it is super easy to include flow-remove-types at any point in your existing build tools.

Built atop the excellent babylon parser, flow-remove-types shares the same parse rules as the source of truth Flow Babel plugins. It also passes through other common non-standard syntax such as JSX and experimental ECMAScript proposals.

Before:

import SomeClass from 'some-module'
import type { SomeInterface } from 'some-module'

export class MyClass<T> extends SomeClass implements SomeInterface {

  value: T

  constructor(value: T) {
    this.value = value
  }

  get(): T {
    return this.value
  }

}

After:

import SomeClass from 'some-module'


export class MyClass    extends SomeClass                          {



  constructor(value   ) {
    this.value = value
  }

  get()    {
    return this.value
  }

}

Use in Build Systems:

Rollup: rollup-plugin-flow

flow-remove-types's People

Contributors

leebyron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.