Skip to content

feat(migrations): add can-load-to-can-match migration for v23 - #71122

Draft
atscott wants to merge 1 commit into
angular:mainfrom
atscott:migrate-canload
Draft

atscott wants to merge 1 commit into
angular:mainfrom
atscott:migrate-canload

Conversation

@atscott

@atscott atscott commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Adds an automated migration for Route.canLoad and CanLoad removal in v23.

Summary of Changes:

  • implements CanLoad -> implements CanMatch: Replaces CanLoad with CanMatch in class heritage clauses. If CanMatch is already implemented on the class, CanLoad is cleanly removed from the clause.
  • Guard Class & Object Members: Renames canLoad methods, properties, and accessors on guard classes (and derived classes) to canMatch. Also migrates object-literal guards.
  • Route Definitions (Route.canLoad -> Route.canMatch): Renames route canLoad property to canMatch. If canMatch is already present on the route object, the guards from canLoad are merged into the canMatch array and canLoad is removed without leaving trailing commas or blank lines.
  • Callsites & Assertions in Tests: Renames direct invocations and references to canMatch in tests (e.g. guard.canLoad(...), TestBed.inject(MyGuard).canLoad(...), spyOn(guard, 'canLoad'), expect(guard.canLoad).toHaveBeenCalled(), and route.canLoad).
  • Imports: Updates @angular/router imports (CanLoad -> CanMatch, CanLoadFn -> CanMatchFn) via ImportManager.

Migrates route.canLoad and class/interface CanLoad implementations to CanMatch ahead of the removal in v23:
- Replaces 'implements CanLoad' with 'implements CanMatch' (or removes CanLoad if CanMatch is already present).
- Renames the 'canLoad' member on guard classes to 'canMatch'.
- Moves route 'canLoad' to 'canMatch' in route definitions (merging elements if 'canMatch' already exists).
- Renames callsites and property references to 'canMatch' in tests (e.g. guard.canLoad(...), TestBed.inject(Guard).canLoad(...), spyOn(guard, 'canLoad'), and expect(guard.canLoad)).
- Updates imports from @angular/router (CanLoad -> CanMatch, CanLoadFn -> CanMatchFn).
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: migrations Issues related to `ng update`/`ng generate` migrations labels Oct 1, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: migrations Issues related to `ng update`/`ng generate` migrations detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant