packages/flow-parser/README.md
This package contains the Flow parser in its JavaScript package form.
See flow.org. The code for the Flow parser lives on GitHub.
The Flow Parser is a JavaScript parser for Flow syntax. It produces an AST that conforms to the ESTree spec. This npm package contains the Flow Rust parser compiled to WASM with JavaScript bindings.
You can use the Flow parser in node:
const {parse} = require('flow-parser');
parse('1+1', {});
The second argument to parse is the options object. Common options:
flow ('detect' or 'all', default 'detect') - parse Flow syntax only with an @flow pragma, or always parse Flow syntaxsourceType ('module', 'script', or 'unambiguous') - parse the file as a module, script, or infer it from the contentstokens (boolean, default false) - include a list of all parsed tokens in a top-level tokens propertybabel (boolean, default false) - return a Babel-shaped ASTenableEnums (boolean, default true) - enable parsing of enumsenableExperimentalFlowMatchSyntax (boolean, default true) - enable parsing of match expressions and match statementsenableExperimentalComponentSyntax (boolean, default true) - enable parsing of component syntaxassertOperator (boolean, default false) - enable parsing of the assert operatorenableExperimentalDecorators (boolean, default true) - enable parsing of decorators