Skip to content

control-flow migration creates $index variable that will not compile in Angular 18 #56152

@mcalmus

Description

@mcalmus

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

The control-flow migration changes code like this:
<div *ngFor="let foo of foos; index as $index;"></div>
into:
@for (foo of foos; track foo; let $index = $index) { <div></div> }
This code, while odd, compiled ok in Angular 17. It no longer compiles in Angular 18. The migration should leave off index variables that are aliased to $index.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

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)state: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions