New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(router): migrate RouterLinkWithHref
references to RouterLink
#47599
feat(router): migrate RouterLinkWithHref
references to RouterLink
#47599
Conversation
1d573f9
to
6098aaf
Compare
packages/core/schematics/migrations/router-link-with-href/util.ts
Outdated
Show resolved
Hide resolved
6098aaf
to
fdd8566
Compare
@crisbeto thanks for the review I've actually rewrote the logic a bit taking into account your comment. Now the process looks like this:
Previously, lookups (to find usages) and rewrites were interleaved, thus susceptible to offset shifts. Could you please take another look when you get a chance? |
Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive and now developers can always import and use the `RouterLink` directive when they need to add a `[routerLink]` in templates. This migration finds all imports and usages of the `RouterLinkWithHref` class and rewrites them to `RouterLink` instead. ```ts import { RouterLinkWithHref } from '@angular/router'; @component({ standalone: true, template: `<a [routerLink]="'/abc'">`, imports: [RouterLinkWithHref] }) export class MyComponent { @ViewChild(RouterLinkWithHref) aLink!: RouterLinkWithHref; } ``` ```ts import { RouterLink } from '@angular/router'; @component({ standalone: true, template: `<a [routerLink]="'/abc'">`, imports: [RouterLink] }) export class MyComponent { @ViewChild(RouterLink) aLink!: RouterLink; } ```
fdd8566
to
0e58432
Compare
This PR was merged into the repository by commit 16c8f55. |
…angular#47599) Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive and now developers can always import and use the `RouterLink` directive when they need to add a `[routerLink]` in templates. This migration finds all imports and usages of the `RouterLinkWithHref` class and rewrites them to `RouterLink` instead. ```ts import { RouterLinkWithHref } from '@angular/router'; @component({ standalone: true, template: `<a [routerLink]="'/abc'">`, imports: [RouterLinkWithHref] }) export class MyComponent { @ViewChild(RouterLinkWithHref) aLink!: RouterLinkWithHref; } ``` ```ts import { RouterLink } from '@angular/router'; @component({ standalone: true, template: `<a [routerLink]="'/abc'">`, imports: [RouterLink] }) export class MyComponent { @ViewChild(RouterLink) aLink!: RouterLink; } ``` PR Close angular#47599
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Since Angular v15, the
RouterLink
contains the logic of theRouterLinkWithHref
directive and now developers can always import and use theRouterLink
directive when they need to add a[routerLink]
in templates. This migration finds all imports and usages of theRouterLinkWithHref
class and rewrites them toRouterLink
instead.PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?