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-6/

Class Type Stripper

Build a tool that removes Flow type annotations from JavaScript class definitions while preserving the runtime behavior.

Requirements

Your implementation should:

  1. Accept JavaScript source code containing Flow-typed class definitions as input
  2. Remove all type-related features from classes including:
    • Type parameters (generics) on class declarations
    • implements clauses
    • Property type annotations
  3. Return clean JavaScript code with all class type features removed
  4. Preserve the exact structure and behavior of the original classes (constructors, methods, initialized properties)
  5. Handle both single classes and files with multiple class definitions

Input/Output Format

Input: A string containing Flow-typed JavaScript code with class definitions

Output: A string containing the same code with class type features removed

Examples

Example 1: Basic class with type features

Input:

class Container<T> implements Storage {
  items: T[];
  count: number = 0;

  constructor() {
    this.items = [];
  }
}

Expected output:

class Container {
  items;
  count = 0;

  constructor() {
    this.items = [];
  }
}

Example 2: Multiple classes with inheritance

Input:

class Base<T> {
  value: T;
}

class Derived<U> extends Base<U> implements Validator {
  valid: boolean = true;
}

Expected output:

class Base {
  value;
}

class Derived extends Base {
  valid = true;
}

Test Cases

  • Given a class with type parameters, it removes the type parameters @test
  • Given a class with an implements clause, it removes the implements clause @test
  • Given a class with property type annotations, it removes the type annotations @test
  • Given a class with all three features combined, it removes all type features @test

Implementation

@generates

API

/**
 * Removes Flow type features from class definitions in JavaScript source code.
 *
 * @param {string} source - JavaScript source code containing Flow-typed classes
 * @returns {string} The transformed JavaScript with class type features removed
 */
function stripClassTypes(source) {
  // IMPLEMENTATION HERE
}

module.exports = { stripClassTypes };

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