LAB -

Upgrading Angular 16 to 22 with an AI Agent: What Broke, and a Prompt You Can Steal

Teodor Cosma Nov 23, 2026

Summary

Angular 20 reaches end of support on 28 November 2026. Angular has also moved to one major release a year, so version 23 is not due until around June 2027, and Angular 22 is supported until June 2028. If your app is anywhere between 16 and 21, Angular 22 is the version to land on.

We walked a production app built on NgRx and Angular Material from Angular 16 to 22, with an AI coding agent (Claude Code) doing the grind and an engineer making the calls. The last hop failed with about 500 errors. The agent traced them to four causes, and the fix was five lines of config. Below is everything that broke at each version, with the error codes and the fix. At the end is a prompt you can give your own agent to run the same upgrade. Jump to the version you are on.

How the agent ran the upgrade

ng update moves one major version at a time, and each major ships its own migrations, so that was the unit of work: six hops, each its own commit. A hop counted as done only when four checks agreed: the compiler, a clean production build, a unit test net and a manual smoke checklist.

Before the first hop, the agent wrote about 90 unit specs over the services, reducers, helpers and main components. They are a safety net for logic and rendering, not a coverage target. The net paid for itself straight away: it found a cast that threw a TypeError whenever a field arrived as an array instead of a string.

A staircase from Angular 16 to 22, one major version per step, with a gold square at the end of every step meaning the compiler, production build, unit net and smoke list all passed. 16: safety net first, a unit net of about 90 specs, which caught a real bug. 17: signal mutate() is gone, replaced by update() returning a new reference; a drag-and-drop library's peer range blocked installs. 18: RxJS 7 generics needed Subject of void; Material m2 names. 19: standalone true became the default; an old NgRx codemod crashed ng update. 20: --force pinned only the named packages, so every @angular package must be pinned. 21: libraries dropped their NgModule APIs, fixed in two module imports. The step to 22 is drawn twice as tall and in gold. It is the wall: about 500 errors from four root causes, detailed in the table below. ANGULAR 16 → 22 · ONE MAJOR PER STEPGATE: COMPILER · PROD BUILD · UNIT NET · SMOKE LIST 16171819202122 BASELINEHOP 1HOP 2HOP 3HOP 4HOP 5HOP 6 THE WALL Safety net firstmutate() is goneRxJS 7 genericsstandalone: true--force pins onlyLibraries drop~500 errors, ~90-spec unit netupdate(), new refSubjectis now the defaultthe named packagesNgModule APIsfour root causes caught a real bugdrag-drop peer pinMaterial m2- names@ngrx codemod crashpin all @angular/*two module importssee the table below
Six hops, each gated before the next. The notes are the breakages that cost real time; each gold square is where the compiler, the production build, the unit net and a smoke list all agreed. The last step is the tall one.

Angular 16 to 17: mutate() is removed from signals

  • WritableSignal.mutate() is gone. Replace it with update(v => ({ ...v, [k]: x })). The callback must return a new reference, because an in-place change notifies nobody.
  • A drag-and-drop library with a strict peer range blocked every npm operation until we bumped it too.
  • Angular Material moved the filled form-field background into a CSS token. Dark input fields turned grey until we set the token.

Angular 17 to 18: RxJS 7 needs Subject<void>

  • new Subject() now infers Subject<unknown>, so .next() needs an argument. Declare new Subject<void>() instead.
  • The schematic applied Material's m2- theming rename for us.

Angular 18 to 19: standalone is the default, and NG6008

standalone now defaults to true, so the migration stamps standalone: false on every component declared in an NgModule. It makes a large diff, and that is expected.

ng update crashed inside an old @ngrx/schematics migration. That package is dev-only code generation, so we removed it.

One trap outlives the upgrade. A component written on a branch that is still on Angular 16 merges in without a standalone flag. Under 19+ that makes it standalone, and declaring it in an NgModule then fails with NG6008. Git merges it cleanly and only the compiler notices, so run this after every merge from such a branch:

for f in $(grep -rlE "@(Component|Directive|Pipe)\(" src --include=*.ts); do
  grep -q standalone "$f" || echo "MISSING: $f"
done

Angular 19 to 20: ng update --force only pins the packages you name

# pins ONLY the packages you name...
ng update @angular/core@20 @angular/cli@20 @angular/cdk@20 @angular/material@20 --force
# ...while the unnamed ones float: common, compiler, forms, router → 21.x, typescript → 6.0

The result is an unbuildable tree. Pin every @angular/* package to the same version by hand, delete node_modules and the lockfile, and reinstall. Either pin the whole family or do not use --force.

Angular 20 to 21: libraries drop their NgModule APIs

Libraries that had fallen several majors behind dropped their NgModule APIs. Hundreds of template errors came from just two module imports: a colour picker that is now a standalone directive, and a scrollbar whose withConfig() became a provider function. Material also renamed its tooltip tokens, which left dark text on a dark tooltip.

ng update also converted dozens of templates to the new @if / @for control flow. Most of the several-thousand-line diff was re-indentation, and *ngIf and *ngFor still work in 22, so we reverted the conversion and left it for its own pull request. QA reviews a version bump, not a rewrite.

Angular 21 to 22: 500 errors from four causes

The last hop broke the build with roughly 500 errors. Sorted by error code and first occurrence, they came down to four causes. All four were configuration, and none were real bugs:

What the build said What it looked like What it actually was
~300 × TS2564 / TS7006 / TS7053 Years of loose code catching up TypeScript 6.0 turns strict on by default, and this codebase was written without it
TS5101 on baseUrl and downlevelIteration A broken tsconfig TypeScript 6.0 promotes deprecation warnings to errors
~180 template errors (TS2739, TS2740, NG8002), then NG4003 Broken forms code, then a compiler bug Angular 22 turns strictTemplates on by default. The migration wrote strictTemplates: false and an extendedDiagnostics block, which requires strictTemplates: true
TS2351 on new JSZip(), TS2349 on saveAs() A library regression TypeScript 6.0 tightened CommonJS interop for import * as

The fix was five lines of config and two imports:

// tsconfig.json
"compilerOptions": {
  "strict": false,              // tightening is its own project, not part of a version bump
  "ignoreDeprecations": "6.0"   
}

// tsconfig.app.json and tsconfig.spec.json: no extendedDiagnostics block
"angularCompilerOptions": { "strictTemplates": false }
import JSZip from 'jszip';
import { saveAs } from 'file-saver';

NgRx had no stable v22 release when we made this hop, so the app stays on NgRx 21, which runs fine under Angular 22. Until NgRx 22 ships, installs need --legacy-peer-deps.

Three Angular 22 migrations that look like noise and must stay

The v22 ng update touched about 90 TypeScript files. It is tempting to revert that as churn, but three of the changes preserve behaviour:

  • changeDetection: ChangeDetectionStrategy.Eager on every component. Angular 22 makes OnPush the default, and Eager is the old always-check behaviour. Drop the stamp and the component silently becomes OnPush, so a component that mutates form state in place stops re-rendering.
  • $safeNavigationMigration(...) around some ?. template expressions. Angular 22 aligned template safe navigation with native optional chaining. The wrapper keeps the old semantics where the two differ.
  • withXhr() on provideHttpClient(...). HttpClient's default backend is now fetch. Keeping XHR preserves upload progress and the existing interceptors.

Eager has the same merge trap as standalone: a component written on a branch still on Angular 16 arrives without the stamp.

Where the AI agent helped

  • Reading the error wall. The agent sorted 500 errors into four causes in minutes and proposed four config fixes instead of 500 code edits.
  • Checking fixes against installed code. Material's theming tokens changed names twice during the upgrade. The agent read the installed package's compiled output to find the current names, instead of trusting documentation or its own memory.

That second move is the one REA ("Reverse Engineer Anything") is built around. REA is an open-source MCP server, with over 470,000 GitHub stars, that gives agents such as Claude Code tools for reading what software actually ships: JavaScript modules and source maps, native binaries, .NET assemblies, network captures. Reading one package's compiled output needed nothing more than the agent's own file reads. For a dependency that ships only minified code, REA is the tool to point at it, on software you are authorised to examine.

The engineer kept the decisions: which hop to run next, what to commit and which changes to keep.

A prompt you can steal

This is not the prompt we used. It is the one we would hand an agent today, with every lesson above built in. Paste it into Claude Code, or any coding agent, at the root of your repository, and fill in the versions.

Upgrade this Angular app from v<FROM> to v<TO>, one major version per hop. You do the work. I make the decisions. Stop at every gate.

Before the first hop:
- Read package.json, angular.json, and every tsconfig. List each third-party Angular library and the Angular versions its peer range allows.
- If the services, stores, and main components have no unit tests, write them first. They are a safety net for logic and rendering, not a coverage target. If they expose a real bug, show me before you fix it.

For each hop from N to N+1:
1. Move every @angular/* package to the same N+1 version. If a library's peer range blocks the update and you need --force, name every @angular/* package in the command, because unnamed ones float to the latest. Then update that library to the major that supports N+1.
2. Leave out optional migrations that change tooling (test runner, builder) or rewrite templates (control-flow syntax). Revert them if they run anyway. They get their own change later.
3. If the build fails with many errors, group them by error code and first occurrence, find the root causes, and show me before you edit code. Prefer one line of config over a hundred code edits.
4. If the new version turns on stricter compiler defaults, keep the old behaviour explicitly and list the tightening as a follow-up.
5. Keep migrations that preserve behaviour, even when the diff looks like noise. Tell me what each one preserves.
6. When a library renamed an API, class, or CSS token, find the current name in the installed package under node_modules, not in docs or memory.
7. Gate: the compiler, a production build, and the unit tests all pass. Then write me a short smoke checklist for what this hop could break.
8. Stop. Summarise what changed, what was deferred, and wait for my approval before starting the next hop.

Rather not run it yourself? If your Angular app is on a version that is sliding out of support and you want it moved carefully, one gated version at a time, talk to Deviqon Labs. A senior engineer replies, not a sales team. Still on AngularJS? ng update cannot help there.

About the Author

Teodor Cosma is a Software Engineer at Deviqon Labs with 3 years of experience in frontend development and tooling automation.

Subscribe to our newsletter

Rest assured we will not misuse your email