Skip to content

generate @angular/core:control-flow failed #55080

@muk-ai

Description

@muk-ai

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

Command fails.

$ npx ng generate @angular/core:control-flow
? Which path in your project should be migrated? ./src/app/components/ui/vi-button2
? Should the migration reformat your templates? Yes
    IMPORTANT! This migration is in developer preview. Use with caution.
Cannot read properties of undefined (reading 'filter')

Minimal Reproduction

The error occurs when the imports is stored in a variable.

const IMPORTS = [CommonModule, ViIconComponent];

@Component({
  selector: 'button[vi-button2]',
  standalone: true,
  imports: IMPORTS,
  templateUrl: './vi-button2.component.html',
  styleUrls: ['./vi-button2.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ViButton2Component {
 : :

Exception or Error

Cannot read properties of undefined (reading 'filter')

Your Environment

$ npx ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 17.3.2
Node: 20.9.0
Package Manager: yarn 1.22.21
OS: linux x64

Angular: 17.3.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1702.0
@angular-devkit/build-angular   17.3.2
@angular-devkit/core            17.3.2
@angular-devkit/schematics      17.3.2
@angular/cdk                    17.2.0
@angular/cli                    17.3.2
@angular/material               17.2.0
@schematics/angular             17.3.2
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.4

Anything else relevant?

It was fixed when I stopped putting imports in the variable. Please refer to this if you get the same error.

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