CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-flow-remove-types

Fast, zero-configuration Flow type annotation removal tool for JavaScript with CLI and programmatic APIs

84

1.09x
Overview
Eval results
Files

task.mdevals/scenario-2/

Flow Type Annotation Remover

Build a command-line utility that removes Flow type annotations from JavaScript files while preserving the original code structure.

Requirements

Your utility should accept JavaScript source code as input and output JavaScript with all type annotations removed. The tool should handle:

  1. Function parameter types: Remove type annotations from function parameters
  2. Return types: Remove return type annotations from functions
  3. Variable types: Remove type annotations from variable declarations

The output should be valid JavaScript that can be executed directly in Node.js without any type checking.

Behavior

  • Accept source code via standard input (stdin) and output to standard output (stdout)
  • Preserve the exact line numbers and whitespace where types were removed (replace types with equivalent whitespace)
  • Process files regardless of whether they have a @flow pragma comment

Examples

Example 1: Function parameter types

Input:

function greet(name: string) {
  return "Hello, " + name;
}

Output:

function greet(name        ) {
  return "Hello, " + name;
}

Example 2: Return types

Input:

function add(a, b): number {
  return a + b;
}

Output:

function add(a, b)         {
  return a + b;
}

Example 3: Variable types

Input:

let count: number = 0;
const message: string = "hello";

Output:

let count         = 0;
const message         = "hello";

Test Cases

  • Removes parameter type annotation from single-parameter function @test
  • Removes return type annotation from function @test
  • Removes type annotation from variable declaration @test
  • Preserves exact line numbers and column positions @test

Implementation

@generates

API

// Read from stdin, write to stdout
// Usage: node type-remover.js < input.js > output.js

Dependencies { .dependencies }

flow-remove-types { .dependency }

Provides Flow type annotation removal functionality.

Install with Tessl CLI

npx tessl i tessl/npm-flow-remove-types

tile.json