Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-235b-a22b-no-thinking· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

What are the best frameworks and tools based on AST and LST for Angular upgrade from…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with grok-3-mini-beta’s answer.
  1. User

    What are the best frameworks and tools based on AST and LST for Angular upgrade from version 11 to Version 20 . How should the upgrade be planned

  2. Qwen Assistant

    Upgrading an Angular application from version 11 to version 20 is a significant leap, as it involves crossing multiple major versions. Angular follows Semantic Versioning (SemVer) and releases new major versions approximately every six months, each introducing breaking changes, deprecations, and improvements.

    To perform this upgrade successfully, especially for large codebases, you can leverage tools based on Abstract Syntax Trees (ASTs) and Lexical Symbol Tables (LSTs) to automate or assist with code transformations, migrations, and refactoring.


    🔧 Tools & Frameworks Based on AST / LST for Angular Upgrade

    1. Angular CLI / Schematics

    • Type: Schematic-based tool using TypeScript AST (ts-morph, typescript compiler).
    • Use: Built-in Angular CLI commands like ng update use schematics that parse your code via AST to apply transformations.
    • Key Features:
      • Automates dependency updates.
      • Applies migration rules for breaking changes.
      • Can be extended with custom schematics.
    • Docs: https://angular.io/cli

    2. ts-morph

    • Type: TypeScript AST manipulation library.
    • Use: Useful for writing custom codemods to migrate deprecated APIs, change imports, or refactor components.
    • Why Use It?
      • Powerful AST traversal and transformation.
      • Easier than raw TypeScript compiler API.
    • Docs: https://ts-morph.com/

    3. jscodeshift

    • Type: Codemod toolkit using Babel parser (AST-based).
    • Use: While not Angular-specific, it's used in the JavaScript ecosystem to write reusable transforms.
    • Can Be Used For:
      • Custom scripts to migrate patterns across files.
      • Especially useful if you have many manual changes to make.
    • Docs: https://github.com/facebook/jscodeshift

    4. Angular Update Tooling (NGT)

    • Type: Internal tool used by Angular team; not public, but its logic powers ng update.
    • You Can Use:
      • The official Angular migration schematics found in @angular/core/schematics/migrations.

    5. Codemods for Angular

    • Community Packages:
      • @angular/cdk/schematics: Contains helpers for material upgrades.
      • @angular/material/schematics: Helps migrate Material design breaking changes.
      • Third-party libraries often provide their own codemods.
    • GitHub Repositories:
      • Search for "angular codemod" or "ng11 to ngXX migration".

    🧭 Strategy for Upgrading Angular from v11 to v20

    Since Angular does not support skipping more than one major version at a time via ng update, you must upgrade incrementally, typically one major version at a time.

    Step-by-Step Upgrade Plan:

    1. ✅ Assess Your Codebase

    • Identify third-party dependencies and check their compatibility.
    • Look for deprecated APIs still in use.
    • Audit build system: Webpack, Rollup, etc., may need updates.

    2. 🛠️ Set Up Development Environment

    • Ensure Node.js and npm/yarn/pnpm versions are compatible with Angular 20.
    • Use Angular CLI v20 for final testing.

    3. ⚙️ Incremental Upgrade Path

    Upgrade one version at a time (e.g., 11 → 12 → 13 → ... → 20). Each step includes:

    StepAction
    1Run ng update @angular/core@<next-version> @angular/cli@<next-version>
    2Fix breaking changes using schematic migrations
    3Review deprecation warnings and fix them
    4Run tests and ensure all features work
    5Commit changes before moving to next version

    4. 📜 Write Custom Migrations Using AST

    If certain changes are repetitive across versions, create custom schematics using:

    • ts-morph to traverse and transform TypeScript files.
    • AST inspection to find and replace outdated patterns.

    Example:

    // Example using ts-morph
    import { Project } from 'ts-morph';
    
    const project = new Project();
    project.addSourceFilesAtPaths('src/**/*.ts');
    
    const sourceFiles = project.getSourceFiles();
    
    sourceFiles.forEach(sourceFile => {
      sourceFile.getDescendantsOfKind(ts.SyntaxKind.Identifier)
        .forEach(identifier => {
          if (identifier.getText() === 'MyDeprecatedService') {
            identifier.rename('NewService');
          }
        });
    });
    

    5. 🧪 Test After Every Major Version

    • Run unit tests (ng test)
    • Run e2e tests (ng e2e)
    • Manually verify critical functionality
    • Monitor browser console for runtime errors

    6. 📦 Update Dependencies

    • Update third-party libraries to match current Angular version.
    • Use tools like npm-check-updates to auto-update package.json.

    7. 🧹 Clean Up

    • Remove deprecated APIs and polyfills no longer needed.
    • Modernize RxJS usage (e.g., pipeable operators).
    • Update Angular Material, CDK, or other UI frameworks.

    8. 🧬 Final Validation

    • Run ng build --prod (or --configuration=production)
    • Test app in production-like environment
    • Ensure performance hasn’t regressed

    📌 Best Practices

    PracticeDescription
    Automate Where PossibleUse schematics and AST-based codemods for repetitive tasks
    Version ControlCommit after each successful upgrade step
    CI IntegrationIntegrate upgrade steps into CI/CD pipeline for regression checks
    DocumentationKeep track of manual fixes and decisions made during upgrade
    Deprecation TrackingRegularly run ng build and watch for deprecation warnings

    🧰 Optional Tools

    ToolPurpose
    Angular ConsoleGUI interface to Angular CLI commands
    Renovate BotAuto-updates dependencies
    Angular DevTools (Chrome Extension)Debugging Angular apps in-browser

    📚 Resources


    ✅ Summary

    To upgrade from Angular 11 to Angular 20:

    • Use Angular CLI + Schematics for automated migrations.
    • Leverage AST-based tools like ts-morph or jscodeshift for custom codemods.
    • Perform the upgrade incrementally, one major version at a time.
    • Validate with tests, manual QA, and performance monitoring.
    • Document and automate everything to reduce risk.

    Would you like a sample custom schematic or codemod script to help with specific changes?

  3. User

    how do these compare with OPenRewrite recipes for Angular upgrade

  4. Qwen Assistant

    Great question!

    OpenRewrite (formerly known as moditect/rewrite) is a powerful, declarative code transformation engine that uses Abstract Syntax Trees (ASTs) to perform safe, repeatable code changes. It's especially useful for large-scale refactoring and version upgrades across multiple projects.

    When comparing Angular CLI Schematics, ts-morph, or jscodeshift with OpenRewrite recipes, here’s how they stack up in the context of an Angular v11 → v20 upgrade:


    🧰 Comparison: OpenRewrite vs Angular Ecosystem Tools

    FeatureOpenRewriteAngular CLI / Schematicsts-morphjscodeshift
    Built-in Angular Support?❌ No native support for Angular (yet)✅ Native support via ng update✅ TypeScript AST focused⚠️ JS-focused, can be adapted
    Declarative Recipes✅ Yes (YAML-based or Java DSL)⚠️ Schematics are imperative⚠️ Imperative API⚠️ Imperative API
    Language Support✅ Java, TypeScript, JavaScript, Kotlin, etc.✅ TypeScript only✅ TypeScript only✅ JavaScript + JSX
    TypeScript AST Support⚠️ Limited (via Babel parser or custom parsers)✅ Full TypeScript compiler✅ Based on TypeScript compiler⚠️ Babel parser (not full TS)
    Community & ToolingGrowing ecosystem (Java-centric)✅ Strong Angular community✅ Good✅ Facebook-backed
    Use Case Fit for Angular Upgrade⚠️ Medium – requires custom recipes✅ High – built by Angular team✅ High – great for codemods✅ Medium – less TS coverage
    IDE Integration✅ IntelliJ, VS Code (plugins), CI tools✅ VS Code + Angular Language Service✅ VS Code plugin support⚠️ Less IDE integration
    Migration Automation✅ Can automate across versions✅ Version-specific migrations✅ Customizable✅ Codemod scripts
    Learning Curve⚠️ Steeper (DSL, Java-based toolchain)✅ Low if using Angular CLI✅ Moderate✅ Moderate

    🔁 How They're Similar

    All these tools use AST-based parsing, which means:

    • They understand your code structure accurately.
    • They avoid fragile regex-based replacements.
    • They allow precise transformations based on language semantics.

    This makes them ideal for tasks like:

    • Renaming imports
    • Updating method signatures
    • Replacing deprecated APIs
    • Refactoring module imports

    🧱 When to Use OpenRewrite Over Angular CLI / ts-morph?

    ✅ Use OpenRewrite when:

    • You're working in a multi-language monorepo (e.g., Java + TypeScript).
    • You want declarative, version-agnostic refactorings.
    • You're planning long-term maintenance of migration rules.
    • You want to run transformations outside of Angular CLI.
    • You're already using OpenRewrite for backend migrations and want to unify tooling.

    Example: If you have Spring Boot services and Angular frontends, and you're migrating both, OpenRewrite could offer a unified strategy.

    ✅ Use Angular CLI / Schematics when:

    • You’re doing a standard Angular major version upgrade.
    • You want officially supported, tested migrations.
    • You don’t need cross-language support.
    • You prefer low-effort automation over customization.

    ✅ Use ts-morph when:

    • You need fine-grained control over TypeScript AST.
    • You're writing custom schematics or codemods.
    • You're integrating into a Node.js-based build pipeline.

    ✅ Use jscodeshift when:

    • You're dealing with legacy JS codebases.
    • You're comfortable writing codemod scripts.
    • You're not strictly limited to TypeScript.

    📦 Sample OpenRewrite Recipe (YAML)

    Here's a basic rewrite recipe for replacing a deprecated service import:

    type: specs.openrewrite.org/v1beta/recipe
    name: com.example.ReplaceOldServiceImport
    displayName: Replace Old Service Import
    description: Migrates usage of DeprecatedService to NewService.
    recipeList:
      - org.openrewrite.ts.ChangeType:
          oldFullyQualifiedTypeName: com.example.OldService
          newFullyQualifiedTypeName: com.example.NewService
    

    You’d then apply it via CLI or Maven/Gradle plugin.


    🧪 Real-World Angular Migration Scenario

    Suppose you're upgrading from Angular 11 to 20 and several breaking changes occur:

    ChangeBest Tool
    Update Renderer to Renderer2Angular CLI / Schematics
    Rename ViewChild({ read }) usagets-morph
    Replace HttpModule with HttpClientModuleOpenRewrite (if part of multi-language repo)
    Fix RxJS pipeable operatorsts-morph or jscodeshift
    Remove enableProdMode() in Ivy appsAngular CLI
    Replace @angular/material breaking changesMaterial schematics

    🧩 Recommendation: Hybrid Strategy

    For large Angular upgrades like v11 → v20, consider this hybrid plan:

    1. Use Angular CLI / Schematics for official migrations between each major version.
    2. Write custom codemods with ts-morph for repetitive manual fixes.
    3. Leverage OpenRewrite if you're also managing backend code or want reusable, declarative recipes.
    4. Automate testing and linting after each step.

    📚 Resources


    Would you like help creating an OpenRewrite recipe for Angular or a custom schematic/codemod for specific breaking changes during your upgrade? I can generate examples!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.