Guide/Parser
Parser
Use parseSync to turn source text into an AST compatible with ESTree. TypeScript and JSX nodes follow typescript-eslint's AST format. Install the package for your runtime first.
Parse a program
Inspect diagnostics before transforming or printing recovered syntax.
Parse TypeScript or JSX
Choose the language explicitly:
Use jsx or tsx for JSX input, and dts for declaration files. Parsing TypeScript preserves its types; it does not compile them away.
Next steps
Walk the AST or generate code.
See the Parser API for input and output types, language and source type options, comments, diagnostics, and source positions.