Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rtsao/strip-flow-types
Remove flow types with tree-sitter
https://github.com/rtsao/strip-flow-types
flow flowtype tree-sitter
Last synced: 4 days ago
JSON representation
Remove flow types with tree-sitter
- Host: GitHub
- URL: https://github.com/rtsao/strip-flow-types
- Owner: rtsao
- Created: 2023-03-11T18:19:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T21:41:26.000Z (over 1 year ago)
- Last Synced: 2024-12-27T14:10:11.077Z (about 1 month ago)
- Topics: flow, flowtype, tree-sitter
- Language: JavaScript
- Homepage:
- Size: 896 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```js
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](https://github.com/tree-sitter/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