{"id":12800,"library":"angular-estree-parser","title":"Angular ESTree Parser","description":"angular-estree-parser is a utility library designed to convert specific Angular template syntax constructs (such as actions, bindings, interpolation expressions, and template bindings) into an Abstract Syntax Tree (AST) that conforms to the ESTree specification. This makes it a critical component for tools like code formatters (e.g., Prettier), linters, and other static analysis tools operating within the Angular ecosystem. The library is currently stable at version 15.4.3 and maintains a reactive release cadence, frequently updating to support new major and minor versions of @angular/compiler as they are released. Its core differentiator lies in its deep integration with @angular/compiler's internal parsing mechanisms, ensuring accuracy and alignment with Angular's evolving syntax, while providing an ESTree-compatible output that is widely understood by the JavaScript tooling ecosystem. Users must explicitly install the appropriate @angular/compiler peer dependency to match their Angular project's version.","status":"active","version":"15.4.3","language":"javascript","source_language":"en","source_url":"https://github.com/prettier/angular-estree-parser","tags":["javascript"],"install":[{"cmd":"npm install angular-estree-parser","lang":"bash","label":"npm"},{"cmd":"yarn add angular-estree-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add angular-estree-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for parsing Angular source code. The library leverages Angular's internal compiler logic to generate ESTree-compatible ASTs.","package":"@angular/compiler","optional":false}],"imports":[{"note":"This is the primary way to import all parsing functions. The library is distributed as an ES Module (ESM).","wrong":"const ngEstreeParser = require('angular-estree-parser');","symbol":"* as ngEstreeParser","correct":"import * as ngEstreeParser from 'angular-estree-parser';"},{"note":"Individual parsing functions like `parseBinding`, `parseAction`, `parseInterpolationExpression`, and `parseTemplateBindings` are named exports.","wrong":"import ngEstreeParser from 'angular-estree-parser'; ngEstreeParser.parseBinding(...);","symbol":"parseBinding","correct":"import { parseBinding } from 'angular-estree-parser';"},{"note":"For type-only imports, use `import type` to ensure they are stripped during compilation and don't introduce runtime dependencies or issues.","wrong":"import { AST } from 'angular-estree-parser';","symbol":"AST","correct":"import type { AST } from 'angular-estree-parser';"}],"quickstart":{"code":"import * as ngEstreeParser from 'angular-estree-parser';\nimport type { AST } from 'angular-estree-parser';\n\n// Example: Parse an Angular binding expression\nconst bindingInput = 'user | uppercase';\nconst bindingAst: AST = ngEstreeParser.parseBinding(bindingInput);\nconsole.log('Binding AST:', JSON.stringify(bindingAst, null, 2));\n\n// Example: Parse an Angular action expression\nconst actionInput = 'onClick($event.target.value, item.id)';\nconst actionAst: AST = ngEstreeParser.parseAction(actionInput);\nconsole.log('Action AST:', JSON.stringify(actionAst, null, 2));\n\n// Example: Parse an Angular interpolation expression\nconst interpolationInput = '{{ title + \" - \" + version }}';\nconst interpolationAst: AST = ngEstreeParser.parseInterpolationExpression(interpolationInput);\nconsole.log('Interpolation AST:', JSON.stringify(interpolationAst, null, 2));","lang":"typescript","description":"Demonstrates how to parse various Angular template expressions (binding, action, interpolation) into ESTree-compatible ASTs using the library's core functions."},"warnings":[{"fix":"Ensure `@angular/compiler` is updated to a compatible version (e.g., `>=21.0.7` for `angular-estree-parser` v15). Run `npm install @angular/compiler@latest` or `yarn upgrade @angular/compiler`.","message":"Version 15.0.0 introduced a breaking change by requiring `@angular/compiler` version `21.0.7` or higher. Projects using older `@angular/compiler` versions will need to upgrade or remain on `angular-estree-parser` v14.x.","severity":"breaking","affected_versions":">=15.0.0"},{"fix":"Always install both packages: `npm install angular-estree-parser @angular/compiler` or `yarn add angular-estree-parser @angular/compiler`.","message":"The `@angular/compiler` package is a peer dependency and must be explicitly installed alongside `angular-estree-parser`. Forgetting to install it will lead to runtime errors (e.g., 'Cannot find module').","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade your Node.js environment to version 20 or newer. Tools like `nvm` or `volta` can help manage Node.js versions efficiently.","message":"The package requires Node.js version 20 or higher, as specified in its `engines` field. Running on older Node.js versions will result in an error upon installation or execution.","severity":"gotcha","affected_versions":">=15.0.0"},{"fix":"Update to `angular-estree-parser` version `15.4.3` or later to ensure correct module resolution and compatibility across environments.","message":"Versions of `angular-estree-parser` prior to `15.4.3` may have had issues with module resolution due to an incorrect `exports` field, potentially affecting compatibility in certain build environments (e.g., specific ESM/CJS interop scenarios).","severity":"gotcha","affected_versions":"<15.4.3"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install `@angular/compiler` using `npm install @angular/compiler` or `yarn add @angular/compiler`. Ensure the version satisfies the `angular-estree-parser` peer dependency range.","cause":"The required `@angular/compiler` peer dependency is missing or not installed in your project.","error":"Error: Cannot find module '@angular/compiler' or its corresponding type declarations."},{"fix":"Ensure you are using `import * as ngEstreeParser from 'angular-estree-parser';` or specific named imports like `import { parseBinding } from 'angular-estree-parser';` in an ESM-compatible environment.","cause":"This usually indicates an incorrect module import. The library primarily uses ES Modules (ESM) with named exports, and attempting to `require()` or use a default import might lead to this error.","error":"TypeError: ngEstreeParser.parseBinding is not a function"},{"fix":"Upgrade your Node.js installation to version 20 or higher. Use `nvm install 20` and `nvm use 20` or similar version management tools.","cause":"Your current Node.js version does not meet the minimum requirement specified by the package's `engines` field.","error":"Error: The \"angular-estree-parser\" package requires Node.js version >= 20. Current version: v18.17.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null}