Skip to content

Strange behavior when migrating input with more than 1 usage in a method #63018

@Armenvardanyan95

Description

@Armenvardanyan95

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

When I migrate a project to signals with the ng generate @angular/core:signal-input-migration command, the presence of certain inputs and manipulations on them cause very strange changed in the code by the migration, namely, the removal of the this keyword, which immediately causes a broken build, even when using the "safe" option instead of "best effort"

Minimal Reproduction

To reproduce this, have a component that declares a decorator-based input of type any named "model", and then manipulate the underlying properties in some methods:

export class TestMigrationComponent {
  @Input() public model: any;
  // =============== API Calls ===============

  public onSaveClick(): void {
      this.model.requisitionId = 145;
      this.model.comment = 'value';
      this.model.status = 8;
      this.model.finilizeReasonId = 4
  }

}

After the migration script runs, it suddenly leaves us with this:

export class TestMigrationComponent {
  public readonly model = input<any>();
  // =============== API Calls ===============

  public onSaveClick(): void {
      model.requisitionId = 145;
      model.comment = 'value';
      model.status = 8;
      model.finilizeReasonId = 4
  }

}

As we can see, this is removed, turning the command into a reference to a non-existent global variable, now breaking the build. This doesn't happen when the input has any other name (as far as I can tell), which makes me wonder if this is somehow connected to model signals. In other cases the migration simply skips the input as intended.

Exception or Error


Your Environment

Angular CLI: 20.1.0
Node: 24.0.0
Package Manager: npm 11.3.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.2001.0
@angular-devkit/build-angular   20.1.0
@angular-devkit/core            20.1.0
@angular-devkit/schematics      20.1.0
@schematics/angular             20.1.0
rxjs                            7.8.2
typescript                      5.8.3
zone.js                         0.15.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: migrationsIssues related to `ng update`/`ng generate` migrationshelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions