Skip to content

bug(typography): migration to v15 error with mat.define-legacy-typography-config conversion #26278

Open
@tchandelle

Description

@tchandelle

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 upgrading from v14 to v15, conversion of mat.define-typography-config() to mat.define-legacy-typography-config() is broken.

Reproduction

Steps to reproduce:

  1. Checkout tchandelle/angular-components@08589da
  2. Upgrade to v15 with npx ng update -C @angular/material@15
  3. See the issue here: https://github.com/tchandelle/angular-components-26278/blob/4d52c4d6673827731ce52eea5e88b44fedd99fd7/src/app/app.component.scss#L3

  1. Have a component scss in v14 like:
@use '@angular/material' as mat;
.foo {
  $typo: mat.define-typography-config();
  > h3 {
    @include mat.typography-level($typo, subheading-2);
  }
}

The component is declared as:

@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: 'foo',
  templateUrl: './foo.component.html',
  styleUrls: ['./foo.component.scss'],
  encapsulation: ViewEncapsulation.None,
}
  1. Upgrade to v15 with npx ng update -C @angular/material@15

Expected Behavior

Should be converted to $typo: mat.define-legacy-typography-config();

Actual Behavior

Converted instead to $typo: mat.define-legacy-typography-configmat.define-legacy-typography-config();

Some are even converted to $typo: mat.define-legacy-typography-configmat.define-legacy-typography-configmat.define-legacy-typography-configmat.define-legacy-typography-configmat.define-legacy-typography-config();.

It seems the number of repetition correlate with the number of level in the scss:

.foo {
  // 1st level > repeated 2 times
  $typo: mat.define-legacy-typography-configmat.define-legacy-typography-config();
  .bar {
    // 2nd levels > repeated 3 times
    $typo: mat.define-legacy-typography-configmat.define-legacy-typography-configmat.define-legacy-typography-config();
  }
}

Environment

  • Angular: 15.0.4 (migrated from 14.2.10)
  • CDK/Material: 15.0.3 (migrated from (14.2.7)
  • Operating System (e.g. Windows, macOS, Ubuntu): darwin x64
  • Node: 18.12.1
  • Package Manager: yarn 3.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: ng-updateIssues related to `ng-update` integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions