Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 799 Bytes

README.md

File metadata and controls

24 lines (15 loc) · 799 Bytes

strip-flow-types

Remove Flow type annotations with tree-sitter

Features

  • Replaces all types with whitespace so line and column numbers are unaffected (no need for source maps)
  • Compiled to native code using Rust bindings for tree-sitter
  • Tested against test suites for Babel and Flow

Usage

import { transform } from "strip-flow-types";

transform(`function foo(a?: number) {}`);
//     => "function foo(a         ) {}"

Limitations

  • Cannot parse uncommon Flow syntax that the tree-sitter-typescript grammar cannot parse (see commented out tests). This can be fixed upstream
  • Does not currently handle the edge case where a paren/brace must be moved to produce valid JS syntax when multiline types are removed