ng-update schematic - object property migration

Discussão em 'Angular' iniciado por Mathias Van den Broek, Outubro 23, 2024.

  1. I'm currently working on an implementation for an ng-update schematic for our internal design system. We have components and interfaces that are renamed between 2 versions of our package. The interfaces sometimes also have renamed properties.

    I'm using the createMigrationSchematicRule method from the @angular/cdk package. I'm providing the following update data to the migration method:

    {
    attributeSelectors: {},
    classNames: {
    [TargetVersion.V17]: [
    {
    pr: '',
    changes: [{ replace: 'Site', replaceWith: 'AppCenterSubject' }]
    }
    ]
    },
    constructorChecks: {},
    cssSelectors: {},
    elementSelectors: {},
    inputNames: {},
    methodCallChecks: {},
    outputNames: {},
    propertyNames: {
    [TargetVersion.V17]: [
    {
    pr: '',
    changes: [
    {
    replace: 'site',
    replaceWith: 'name',
    limitedTo: { classes: ['Site'] }
    }
    ]
    }
    ]
    },
    symbolRemoval: {}
    }


    When I'm running my schematic on this component:

    @Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
    })
    export class AppComponent {
    public value: Site = {
    site: 'Site',
    group: 'Group'
    };
    }


    I get the following output:

    @Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
    })
    export class AppComponent {
    public value: AppCenterSubject = {
    site: 'Site',
    group: 'Group'
    };
    }


    So the Site interface is migrated to the new AppCenterSubject interface, but the site property of the value object is not migrated to the new name property. Am I missing something, or is this just not possible at all?

    Continue reading...

Compartilhe esta Página