Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Migration][Schematics]: v14 inject migration schematics fails to properly migrate destructured dependency #62626

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

Description

@bougwal

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

compiler-cli

Is this a regression?

No

Description

Hi guys,
While finishing up a relatively large scale migration (to functional injection with v14) instead of constructor based injection, a recurring pattern of failures required manual interventions here and there to fix up the migration failures of de-structured injectable dependencies where the schematics was effectively deleting the dependency all together such as in below example.

export class App {  protected title = 'migrator-failure'; //This should be migrated to inject properly, but it fails!  constructor({nativeElement}: ElementRef){    console.log(nativeElement)  }}

The codebase was full of this pattern which is valid and works perfectly fine in constructor based injection context.

The expectation here would be rather something relatively as

export class App {  protected title = 'migrator-failure';  nativeELement = inject(ElementRef).nativeElement;  constructor(){    console.log(this.nativeElement)  }}

Yet, what it produces is deleting theElementRef all together.

export class App {  protected title = 'migrator-failure';  //Emptied the constructor without proper migration/transformation to use v14 inject()!   constructor(){    console.log(nativeElement)  }}

While migration is effectively done after manual interventions and everything is running perfectly fine on prod, this tiny hiccup (among other one which is aliasing injectables randomly - I will try to reproduce and report separately) can be improved if you evaluate it as a valid case (which is something i believe worth having a look at) and there is room to look at it.


I have put a tiny repro repo here with separate commits to show case this (Still effectively occurs with v20).

Repo:https://github.com/bougwal/migrator-destructure-failure
Initial commit:R8-R13
post-migration result commit: R10-R17


Please provide a link to a minimal reproduction of the bug

https://github.com/bougwal/migrator-destructure-failure

Please provide the exception or error you saw

N/A

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

Details in the repo // If any more info is needed please ask below and i will provide. Yet, I think what's in the repo is sufficient to reproduce

Anything else?

PS: I didn't find an open/closed issue relevant to this, but if there is any, please let me know linking it below as dup. Many thanks !

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

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp