Buntis
A 100% compliant, self-hosted Typescript parser that emits an ESTree-compatible abstract syntax tree
Features
- Conforms to the standard ECMAScript® 2020 (ECMA-262 10th Edition) language specification
- Conforms to the latest Typescript language specification
- Support TC39 proposals via option (wip)
- Support for additional ECMAScript features for Web Browsers
- JSX / TSX support via option
- Optionally track syntactic node locations (wip)
- Emits an ESTree-compatible abstract syntax tree
- No backtracking
- Low memory usage
- Very well tested (~16 000 unit tests with full code coverage)
- Lightweight - ~85 KB minified
Installation
npm install buntis --save-dev
API
Buntis generates AST
according to ESTree AST format, and can be used to perform syntactic analysis (parsing) of a Javascript
or Typescript
program, and with ES2015
and later a JavaScript program can be either a script or a module. The same methods are used when parsing in Typescript
mode - parseTSModule
and parseTSScript
.
The parse
methods exposed by Buntis takes an optional options
object which allows you to specify whether to parse in script
mode (the default) or in module
mode or Typescript
mode.
This is the available options:
Example usage:
; parseTSScript'const f = function<T>(x?: T): T {}';
This will return when serialized in json: