Fast, zero-configuration Flow type annotation removal tool for JavaScript with CLI and programmatic APIs
84
Build a tool that processes JavaScript source code containing Flow type assertions and removes them to produce standard JavaScript output.
Create a utility that transforms JavaScript code by removing Flow type assertions (both as Type expressions and as const assertions) while preserving all runtime behavior and code structure.
Your tool should:
value as Typevalue as constExample 1: Basic type assertion
// Input
const x = someValue as number;
// Output
const x = someValue;Example 2: Const assertion
// Input
const config = { name: 'app' } as const;
// Output
const config = { name: 'app' };Example 3: Multiple assertions
// Input
function process(data) {
const id = data.id as string;
const count = data.count as number;
return { id, count } as const;
}
// Output
function process(data) {
const id = data.id;
const count = data.count;
return { id, count };
}value as Type) and removes only the assertion @testvalue as const) and removes only the assertion @test@generates
/**
* Removes Flow type assertions from JavaScript source code.
*
* @param {string} source - The JavaScript source code containing Flow type assertions
* @returns {string} The transformed JavaScript code with type assertions removed
*/
function stripTypeAssertions(source) {
// IMPLEMENTATION HERE
}
module.exports = { stripTypeAssertions };Provides Flow type annotation removal capabilities including type assertion stripping.
Install with Tessl CLI
npx tessl i tessl/npm-flow-remove-typesevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10