or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mddevelopment-integration.mdindex.mdprogrammatic-api.md
tile.json

index.mddocs/

Flow Remove Types

Flow Remove Types is a fast, zero-configuration tool for removing Flow type annotations from JavaScript files. It provides both command-line and programmatic APIs, serving as a lightweight alternative to Babel for type stripping with minimal dependencies and maximum performance.

Package Information

  • Package Name: flow-remove-types
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install flow-remove-types

Core Imports

const flowRemoveTypes = require('flow-remove-types');

For require hook:

require('flow-remove-types/register');

For Jest integration:

// jest.config.js
module.exports = {
  transform: {
    "^.+\\.js(?:\\.flow)?$": "flow-remove-types/jest"
  }
};

Basic Usage

const flowRemoveTypes = require('flow-remove-types');
const fs = require('fs');

// Read Flow-typed source
const input = fs.readFileSync('input.js', 'utf8');

// Remove types
const result = flowRemoveTypes(input, { 
  pretty: false,  // Keep whitespace for exact positioning
  all: false      // Only process files with @flow pragma
});

// Get transformed code
const output = result.toString();
fs.writeFileSync('output.js', output);

// Generate source map if needed
const sourceMap = result.generateMap();

Architecture

Flow Remove Types is built around several key components:

  • Core Parser: Uses hermes-parser (Flow's official ECMAScript parser) for accurate Flow syntax parsing
  • Transform Engine: Visitor-based AST transformation that removes Flow-specific nodes while preserving exact positioning
  • CLI Tools: Command-line interface and flow-node REPL for development workflows
  • Integration Layer: Require hooks using pirates library, Jest transformers, and build tool plugins
  • Source Map Support: VLQ-encoded source map generation with configurable pretty printing

Capabilities

Programmatic API

Core transformation function for removing Flow type annotations from JavaScript source code with configurable options.

function flowRemoveTypes(source, options);

Programmatic API

Command Line Interface

Fast CLI tool for transforming Flow files with support for single files, directories, and advanced options like source maps.

flow-remove-types [options] [sources]
flow-node [options] [script.js] [arguments]

Command Line Interface

Development Integration

Automatic compilation hooks and transformers for seamless development workflow integration.

require('flow-remove-types/register')(options);

Development Integration

Core Types

interface TransformResult {
  toString(): string;
  generateMap(): SourceMap;
}

interface TransformOptions {
  all?: boolean;
  pretty?: boolean;
  ignoreUninitializedFields?: boolean;
  removeEmptyImports?: boolean;
}

interface SourceMap {
  version: number;
  sources: string[];
  names: string[];
  mappings: string;
  file?: string;
  sourcesContent?: string[];
}