Fast, zero-configuration Flow type annotation removal tool for JavaScript with CLI and programmatic APIs
84
Create a command-line utility that evaluates Flow-typed JavaScript expressions dynamically using the flow-node evaluation modes.
Your utility should accept Flow-typed JavaScript code snippets and evaluate them, returning results in different formats based on command-line options.
The utility should accept JavaScript expressions as command-line arguments and evaluate them:
The utility must support two evaluation modes:
The mode should be selectable via a command-line flag --mode which accepts values eval or print.
@generates
/**
* Evaluates a Flow-typed JavaScript expression using the specified mode.
*
* @param {string} code - The JavaScript code to evaluate
* @param {string} mode - Either "eval" or "print"
* @returns {Promise<{stdout: string, stderr: string, exitCode: number}>}
*/
async function evaluateExpression(code, mode) {
// Implementation uses flow-node with appropriate flags
}
/**
* Main CLI handler
*/
async function main() {
// Parse command line arguments
// Call evaluateExpression with the code and mode
// Display output appropriately
}
module.exports = { evaluateExpression, main };"2 + 2" with mode "print", the evaluator prints 4 to stdout @test"const x: number = 5; x * 2" with mode "print", the evaluator prints 10 @test"console.log('hello')" with mode "eval", the evaluator outputs hello (from console.log) but does not print the return value @test"const sum = (a: number, b: number): number => a + b; sum(3, 7)" with mode "print", the evaluator prints 10 @testProvides Flow type annotation removal and flow-node execution capabilities.
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