// This definition file follows a somewhat unusual format. ESTree allows// runtime type checks based on the `type` parameter. In order to explain this// to typescript we want to use discriminated union types:// https://github.com/Microsoft/TypeScript/pull/9163//// For ESTree this is a bit tricky because the high level interfaces like// Node or Function are pulling double duty. We want to pass common fields down// to the interfaces that extend them (like Identifier or// ArrowFunctionExpression), but you can't extend a type union or enforce// common fields on them. So we've split the high level interfaces into two// types, a base type which passes down inherited fields, and a type union of// all types which extend the base type. Only the type union is exported, and// the union is how other types refer to the collection of inheriting types.//// This makes the definitions file here somewhat more difficult to maintain,// but it has the notable advantage of making ESTree much easier to use as// an end user.
When JavaScript code is parsed by tools like Babel, ESLint, or TypeScript, it’s converted into an AST, which is a tree-like representation of the code’s syntax. Different tools initially had different AST formats, so ESTree was created to provide a consistent structure for interoperability.