Skip to content

Control flow migration issue: templates are not deleted #56965

@szape89

Description

@szape89

Command

generate

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

After running the control flow migration, used templates are not deleted.

Before:

<div>
  <div *ngIf="param; else loading">
    <div>content</div>
  </div>
  <ng-template #loading>
    <div>loading</div>
  </ng-template>
</div>

After:

<div>
  @if (param) {
    <div>
      <div>content</div>
    </div>
  } @else {
    <div>loading</div>
  }
  <ng-template #loading>
    <div>loading</div>
  </ng-template>
</div>

Expected result would be that the used template is removed or at least there is a comment added with explanation.

Minimal Reproduction

Commands:

  • npx @angular/cli@17 new angular-18-migration-issues
  • ng update @angular/core@18 @angular/cli@18
  • ng g @angular/core:control-flow

Example commit: szape89/angular-18-migration-issues@f3f2548

Exception or Error

No response

Your Environment

Angular CLI: 18.1.0
Node: 20.15.0
Package Manager: npm 10.7.0
OS: win32 x64

Angular: 18.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0
@angular-devkit/build-angular   18.1.0
@angular-devkit/core            18.1.0
@angular-devkit/schematics      18.1.0
@schematics/angular             18.1.0
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.7

Anything else relevant?

No response

Metadata

Metadata

Assignees

Labels

area: migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions